-1

i'm trying to connect to access database on my ubuntu 18 but i cant

self.con = pyodbc.connect(
r'Driver={Microsoft Access Driver (*.accdb)};'
r'DBQ=C:\Users\Derar\PycharmProjects\ULMS\ulms.accdb;PWD=v7WC$=3ZJ5pX?h?TM54S')
self.cmd = self.con.cursor()

I Get This Error

''`r'DBQ=C:\Users\Derar\PycharmProjects\ULMS\ulms.accdb;PWD=v7WC$=3ZJ5pX?h?TM54S')
pyodbc.InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')`
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
Derar
  • 97
  • 14
  • Have you installed an Access ODBC driver for Linux? (Hint: Linux does not include an Access ODBC driver by default, and Microsoft does not provide Access ODBC drivers for non-Windows platforms.) – Gord Thompson Jun 27 '18 at 01:18
  • Possible duplicate of [Working with an Access database in Python on non-Windows platform (Linux or Mac)](https://stackoverflow.com/questions/25596737/working-with-an-access-database-in-python-on-non-windows-platform-linux-or-mac) – Gord Thompson Jul 22 '18 at 23:51

2 Answers2

1

It looks like your trying to run code written for Windows on Ubuntu. It looks like the path name is not a POSIX style path.

You will need to configure linux odbc properly - or just install python on Windows and run your code there...

As far as I know there is no free linux ODBC driver for accdb files. You would likely have to convert the database, use commercial software, or access the DB from Windows.

Jayme Snyder
  • 101
  • 3
  • This appears to be some commercial software which can provide Access file format support in linux... https://www.easysoft.com/products/data_access/odbc-access-driver/index.html#section=tab-1 Instructions for configuring it are here: https://www.easysoft.com/products/data_access/odbc-access-driver/getting-started.html You'll obviously need to copy the access file or mount it over an SMB/CIFS share and modify your /etc/odbc.ini file accordingly – Jayme Snyder Jun 27 '18 at 01:23
-2

See my answer here:

Connect to MS Access in Python

I believe it's applicable to your scenario.

ASH
  • 20,759
  • 19
  • 87
  • 200
  • *"I believe it's applicable to your scenario."* - No, it isn't. Your linked(-only) answer and the blog post it cites are for a Windows environment. Microsoft does not produce an Access ODBC driver for non-Windows platforms. See [this question](https://stackoverflow.com/questions/25596737/working-with-an-access-database-in-python-on-non-windows-platform-linux-or-mac) for details. – Gord Thompson Jul 22 '18 at 23:55