PySQLite

From Dabo Wiki
Jump to: navigation, search

PySQLite is a python wrapper for the SQLite database. SQLite is a small, embeddable, FAST database library written in C. It is somewhere around 20k lines of code, and in the public domain. See the SQLite page for more information.

Typical usage of SQLite might be: On a webserver where you would like a database, but not the hassle of all the functionality offered by more advanced dB's such as MySQL or PostgreSQL. Embedded within your application. If you simply want a datastore that is more advanced than text based access and don't want to "roll your own" solution. Other ideas?

Home pages: SQLite and PySQLite

To create or modify an instance of a database, simply:

import sqlite
# if the dB doesnt exist, it will be created for you:
db = sqlite.connect('somedb')
curs = db.cursor()
curs.execute('SELECT * FROM some_table')
curs.execute('INSERT INTO some_table VALUES (some_value, another_value, etc)')
db.commit() # Note, without this commit the previous query sits in limbo
db.close()

I highly recommend checking the tools out - they're easy to use, yet extremely powerful. Good luck!