| PyDbLite |
PyDbLite is a pure-Python in-memory database engine, using Python list comprehensions as query language, instead of SQL
It consists of one small module, PyDbLite.py. The package also provides two modules,
SQLite.py and MySQL.py. They use SQLite and MySQL backends with the
same Pythonic syntax as the pure-Python PyDbLite engine
To install the package, just download it and install it by running >python setup.py install
Base from module PyDbLite : from PyDbLite import Base
cPickle module : strings, Unicode strings, integers,
floats, dates and datetimes (instances of the date and datetime classes in the datetime module), user-defined classes, etc
create() method, to specify what
you want to do if the base already exists in the file system
IOError is raised
None
create() method
create() method, an internal field called __id__ is added. It is a integer which is guaranteed to be unique and unchanged for each record in the base, so that it can be used as the record identifier
__version__ is also managed by the database engine. It is a integer which is set to 0 when the record is created, then incremented by 1 each time the record is updated. This is used to detect concurrency control, for instance in a web application where 2 users select the same record and want to update it at the same time
_age : note the heading underscore, to avoid name conflicts with internal names). This attribute is a dictionary-like object, where keys are the values taken by the field, and values are the records whose field values are egal to the key :
keys() method
returns all existing values for the field
list_of_records can be any iterable (list, tuple, set, etc) yielding records
None
The only difference with the pure-Python module is the syntax to identify a Base and the need to specify field types on base creation
Base :
from PyDbLite.SQLite import Base
Base instance (a table in the SQLite database) you pass the connection as argument : db = Base('dummy',connection)
For convenience, you can also use the types DATE and DATETIME (or TIMESTAMP), the package will
transparently manage the conversions between the datetime.date and
datetime.datetime and the TEXT type
For record insertion, selection, update and deletion, the syntax is the same as above. The only difference is that you can't use the drop_field() method, since dropping fields is not supported by SQLite
The Base instance has an attribute cursor, so you can also execute
SQL expressions by db.cursor.execute(some_sql) and get the result
by results = db.cursor.fetchall()