Friday, June 1, 2007

Getting SQLite Working

Steps I needed to go through to be able to use SQLite in my python programs. This was on my linux box, I haven't tried it on my micros~1 laptop...
  1. Download python2.5 and compile. This has the sqlite3 module built in - but it's only a wrapper!
  2. Download and compile sqlite3. Initial trials bombed out when looking for 'tcl.h'. I don't need TCL bindings, so a quick look on the sqlite wiki says to 'configure --disable-tcl'. This seemed to do the trick.
  3. As Python only includes the wrapper for sqlite, I needed to run the script again so that Python knows where to find the sqlite executable. I needed to hack the because I'm not installing sqlite in the usual place.
    To do this, I searched for sqlite3 and added the sqlite build directory path to sqlite_inc_paths - it'll pick up sqlite3.h here. Then, I added os.path.join(sqlite_incdir, '.libs') to the sqlite_dirs_to_check list - my libraries were linked into bld/.libs
  4. Running Python again and doing a 'import sqlite3' is quiet - which means no errors! Job done.

No comments: