-
Notifications
You must be signed in to change notification settings - Fork 564
Connecting to SQLite
Moritz Duchêne edited this page Jul 7, 2022
·
3 revisions
Note that Python has built-in support for SQLite3 so you may not need to use ODBC at all.
For Windows, you can get the SQLite ODBC driver here. Download "sqliteodbc.exe" if you are using 32-bit Python, or "sqliteodbc_w64.exe" if you are using 64-bit Python.
For Linux, check your distribution's repositories for a pre-configured version of the driver. For example, on Ubuntu 18.04 you can simply use
sudo apt install libsqliteodbc
to install the driver.
On both Windows and Linux the driver name is "SQLite3 ODBC Driver".
For the connection string, use something like
cnxn = pyodbc.connect("Driver=SQLite3;Database=sqlite.db")