SQLite

From Dabo Wiki
Jump to: navigation, search

A simple, free SQL engine, completely self-contained. As far as I can tell, you instantiate it, read in a SQL file (consisting of plain SQL statements), and then query/update/insert against that SQL, and then output it to a file again when you are done. I hope there is an easy way to just point it at a file and be done with it, however.

See the SQLite site for more info.

Installing on Linux:

  • Download sqlite-2.8.15.tar.gz from http://www.sqlite.org/download.html (Note: I was unsuccessful getting PySQLite to build after installing sqlite-3.0.6. I think that it was a combination of things: sqlite3. instead of sqlite. mostly though.)
  • Execute the following shell commands:
tar -xzvf sqlite-2.8.15.tar.gz
cd sqlite
mkdir bld
  • Edit Makefile-linux.gcc and uncomment line 35, and comment line 36. The section should now look like:
#    If you want the SQLite library to be safe for use within a
#    multi-threaded program, then define the following macro
#    appropriately:
#
THREADSAFE = -DTHREADSAFE=1
#THREADSAFE = -DTHREADSAFE=0
  • Execute:
cd bld
../configure
make
sudo make install
tar -xzvf pysqlite-0.5.1.tar.gz
cd sqlite
python2.3 setup.py build
sudo python2.3 setup.py install
sudo /sbin/ldconfig
  • Start Python and make sure it imports:
[pmcnett@sol pmcnett]$ python
Python 2.3.2 (#1, Oct  6 2003, 10:07:16)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite
>>> dir(sqlite)
[BINARY, Binary, Connection, Cursor, DATE, DBAPITypeObject, DataError, DatabaseError, Error, INT, IntegrityError, InterfaceError, InternalError, NUMBER, NotSupportedError, OperationalError, PgResultSet, ProgrammingError, ROWID, STRING, TIME, TIMESTAMP, UNICODESTRING, Warning, __all__, __builtins__, __doc__, __file__, __name__, __path__, __revision__, _sqlite, apilevel, connect, decode, encode, main, paramstyle, threadsafety, version, 'version_info']
>>>