How do I install sqlite3 ODBC drivers with unixODBC?
In order to deal with configure: error: No usable SQLite header/library on this system
, one has to:
sudo apt-get install libsqlite3-dev
You might still get the following error after you do so:
configure: error: ODBC header files and/or libraries not found
In that case, do:
sudo apt-get install unixodbc-dev unixodbc-bin unixodbc
You might already have some of the packages listed there, but if you are getting the error, you are missing unixodbc-dev
.
Alright, now you should:
1) ./configure && make
without issues
2) instead of make install
check out the instructions here to learn all about checkinstall
: I installed a program by getting its source code, and then running `sudo make install`; how to make `apt-get` know about it?
Now, reading further into the [instructions] provided for the sqliteodbc
driver, we have to:
1) set up odbcinst.ini
correctly
Open up the odbcinst.ini
in an editor (you will probably need superuser abilities, and you will need to know where the file is -- usually it is in /etc, so we can do: sudo gedit /etc/odbcinst.ini
), and add the following:
[SQLite3]
Description=SQLite ODBC Driver
Driver=/usr/local/lib/libsqlite3odbc.so
Setup=/usr/local/lib/libsqlite3odbc.so
Threading=4
Set up Description
with any string you'd like, but make sure Driver
and Setup
have the right paths to the *.so
provided by install the sqliteodbc
driver. In order to figure out/confirm which *.so
were provided: either grep
or just open up /usr/local/lib/
and check out which *.so
files you have. For instance, according to the example in the instruction, you should point to /usr/local/lib/libsqliteodbc.so
, but I only had /usr/local/lib/libsqlite3odbc.so
. If you have both, you could make two entries like so:
[SQLite3]
Description=SQLite ODBC Driver
Driver=/usr/local/lib/libsqlite3odbc.so
Setup=/usr/local/lib/libsqlite3odbc.so
Threading=2
[SQLite]
Description=SQLite ODBC Driver
Driver=/usr/local/lib/libsqliteodbc.so
Setup=/usr/local/lib/libsqliteodbc.so
Threading=2
Also, make sure you choose some decent value for threading. For instance, if you have 8 cores, maybe Threading=4
will make sense.
For the sake of step 2, I am going to set up things as:
[MYGOOFYSQLITE3DRIVERTAG]
Description=SQLite ODBC Driver
Driver=/usr/local/lib/libsqlite3odbc.so
Setup=/usr/local/lib/libsqlite3odbc.so
Threading=2
2) optional: setup a DNS in ~/.odbc.ini
--- just follow the instructions, but note that you can also use SQLite/3 DNS-less. For instance, using pyodbc
and Python:
import pyodbc
connection_string = "Driver=MYGOOFYSQLITE3DRIVERTAG;Database=/path/to/database.db"
connection = pyodbc.connect(connection_string)
Note that for Driver
key, I referred to the tag I gave the driver in odbcinst.ini
. Maybe you want to be goofy, maybe you don't -- the point is that the key depends on what you set up, or what some other program automatically set up, so if you need to know what the Driver is called, look it up in odbcinst.ini
.
Further details regarding what can go into the connection string can be found in the instructions for the sqliteodbc
driver which we have referred to before.
Related videos on Youtube
Admin
Updated on November 29, 2022Comments
-
Admin over 1 year
According to the unixODBC drivers page (straight out of the 90s), I should download the SQLite3 drivers from: http://www.ch-werner.de/sqliteodbc
The instructions for building
sqliteodbc
from the source code provided on that page is available here: http://www.ch-werner.de/sqliteodbc/html/index.htmlAccording to that page, we should untar the source into a directory, and then run the following commands:
1)
./configure
2)make
3)make install
However, when I run
./configure
in the directory, I get the following error:configure: error: No usable SQLite header/library on this system
What should I do?