1

I compile the program to connect to ms access database as follow:

conn_string = (
    r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
    r'DBQ=C:\folder_name\EVT_LOG.mdb;')

And this works fine as intended.

Then I try to deploy into remote server/client situation where the database is located in the client and server have to access it, so I revamped the connection string as follow:

conn_string = (
    r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
    r'DBQ=\\10.80.112.81\folder_name\EVT_LOG.mdb;')

This one got pyodbc.error data source name not found. Any idea on doing this pyodbc on remote database?

  • 3
    Are you able to reach the file by address `\\10.80.112.81\folder_name\EVT_LOG.mdb` from windows explorer? Check this first. – Sergey S. Sep 28 '17 at 05:37
  • Yes I can reach it from windows explorer, but the problem doesnt lies in the script, it was because no odbc driver installed. Thanks for the answer. – Edwin Purwanto Sep 29 '17 at 03:23

1 Answers1

2

Yes, an IP address can be used as the server name in a UNC path. The database file must be accessible from the Windows file system on the machine running the Python script, and its location can be specified as a local file ...

C:\folder_name\EVT_LOG.mdb

... a file on a network share mapped to a drive letter ...

W:\some_folder\EVT_LOG.mdb

... a UNC path that uses the server name ...

\\server_name\share_name\some_folder\EVT_LOG.mdb

... or a UNC path that uses the server IP address ...

\\10.80.112.81\share_name\some_folder\EVT_LOG.mdb

Note, however, that Windows file sharing (sometimes referred to as SMB or CIFS) is almost never directly accessible over the Internet, so for practical purposes the server that is hosting the database file must either be on your local network, on a secure WAN, or made available over a VPN connection. In each of those cases it is very likely that the server will be available by name, so the IP form of the UNC path is not often used.

Also remember that the file must be accessible using Windows file sharing, not some other Internet protocol like HTTP, FTP, etc..

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
  • Thank you very much for the explanation. This is actually correct, no problem from the script itself. The problem I found was on the windows server it self doesnt contain odbc. after doing what is done here, it was solved: https://stackoverflow.com/questions/27952893/pyodbc-connection-to-mdb-file?rq=1 – Edwin Purwanto Sep 29 '17 at 03:20