Module ezsqlobject :: Class EzSqlDb
[show private | hide private]
[frames | no frames]

Class EzSqlDb

Known Subclasses:
EzDbmDb, EzFirebirdDb, EzMysqlDb, EzPostgresDb, EzSqliteDb

Abstracts an SQL database into an object, whose attribute 'tables' contains a list of existing tables in the database. Accessing a table via attribute access returns a subclass of SQLObject (with an added attribute 'columns', a list of columns).

You cannot use this class directly - use the database-specific classes such as 'mysqlobj', defined in this module

See module doco for example usage

Adds the following conveniences:
Method Summary
  __init__(self, *args, **kw)
  __getattr__(self, name)
  createNewlyAddedTables(self)
  defTable(self, _tablename, **kw)
Returns a class object defining an SQLObject table
  doQuery(self, query)
Executes/returns an arbitrary MySQL query
  dropTable(self, tablename, ifExists, dropJoinTables)
Removes a table from the database.
  dump(self)
Interactive utility which dumps out the whole db
  sync(self)
Reads a list of tables from the database
  tableFromDb(self, name)
  _log(self, level, msg)

Method Details

defTable(self, _tablename=None, **kw)

Returns a class object defining an SQLObject table

Creates the table in the database, but ONLY if it's not already present

Arguments:
  • name - name of table
Keywords:
  • autoCreate - whether to create the table immediately - default True
  • createJoinTables - whether to create join tables, default True
  • a bunch of name=columdef pairs, eg 'firstName=StringCol()'

doQuery(self, query)

Executes/returns an arbitrary MySQL query

dropTable(self, tablename, ifExists=False, dropJoinTables=True)

Removes a table from the database.

Arguments:
  • tablename - name of table to drop
  • ifExists - only try to drop if table already exists (default False)
  • dropJoinTables - drop intermediate join tables (default True)

dump(self)

Interactive utility which dumps out the whole db

sync(self)

Reads a list of tables from the database

Generated by Epydoc 2.0 on Fri Mar 26 13:22:45 2004 http://epydoc.sf.net