Module database :: Class Database
[show private | hide private]
[frames | no frames]

Class Database


Method Summary
  __init__(self, filename, virtualtables)
@param filename: database filename...
  __del__(self)
  __enter__(self)
  __exit__(self, ex_type, ex_value, tb)
  doestableexist(self, tablename)
  getcolumns(self, tablename, onlynames)
  sql(self, statement, params)
Executes statement and return a generator of the results
  sqlmany(self, statement, params)
execute statements repeatedly with params
  updateindirecttable(self, tablename, indirects)
  _altertable(self, tablename, columnstoadd, columnstodel, createindex)
Alters the named table by deleting the specified columns, and adding the listed columns
  _getindirect(self, what)
Gets a list of values (indirect) as described by what
  _rowtrace(self, *row)
  _sqltrace(self, cmd, bindings)
  deleteold(*args, **kwargs)
Deletes old entries from the database.
  getchangescount(*args, **kwargs)
Return the number of additions, deletions, and modifications made to this table over time.
  getmajordictvalues(*args, **kwargs)
  loadlist(*args, **kwargs)
Loads a list of items (eg categories)
  savelist(*args, **kwargs)
Just save a list of items (eg categories).
  savemajordict(*args, **kwargs)
This is the entrypoint for saving a first level dictionary such as the phonebook or calendar.

Method Details

__init__(self, filename, virtualtables=None)
(Constructor)

@param filename: database filename
@param virtualtables: a list of dict specifying the virtual tables
    Each dict is expected to have the following keys:
    'tablename': the name of the virtual table
    'modulename': the name of the module that implements this virtual
        table
    'moduleclass': the ModuleBase subclass that implements this
        virtual table
    'args': arguments passed to instantiaion of the module class

sql(self, statement, params=())

Executes statement and return a generator of the results

sqlmany(self, statement, params)

execute statements repeatedly with params

_altertable(self, tablename, columnstoadd, columnstodel, createindex=0)

Alters the named table by deleting the specified columns, and adding the listed columns
Parameters:
tablename - name of the table to alter
columnstoadd - a list of (name,type) of the columns to add
columnstodel - a list name of the columns to delete
createindex - what sort of index to create. 0 means none, 1 means on just __uid__ and 2 is on all data columns

_getindirect(self, what)

Gets a list of values (indirect) as described by what
Parameters:
what - what to get - eg phonebook_serials,1,3,5, (note there is always a trailing comma)

deleteold(*args, **kwargs)

Deletes old entries from the database. The deletion is based on either criterion of maximum values or age of values matching.
Returns:
number of rows removed,number of rows remaining

getchangescount(*args, **kwargs)

Return the number of additions, deletions, and modifications made to this table over time. Expected fields containted in this table: __timestamp__,__deleted__, __uid__ Assuming that both __rowid__ and __timestamp__ values are both ascending

loadlist(*args, **kwargs)

Loads a list of items (eg categories)

savelist(*args, **kwargs)

Just save a list of items (eg categories). There is no versioning or transaction history.

Internally the table has two fields. One is the actual value and the other indicates if the item is deleted.

savemajordict(*args, **kwargs)

This is the entrypoint for saving a first level dictionary such as the phonebook or calendar.

Generated by Epydoc 2.1 on Fri Aug 15 18:58:32 2008 http://epydoc.sf.net