Subsections

5 pyorq.interface -- The database interfaces

5.1 pyorq.interface.db_base -- The interface definition

This module defines the abstract base class for all database interfaces.

Ths module is used internally by PyORQ, You don't need this information to use the databases

class db_base

The following methods constitute the external interface of the database interfaces

register_class( cls)
Register class cls with the database.

This method is called by ptype.__init__. If the class was not previously registered, a table will be created.

get_instance( cls, *args, **kwargs)
Invoked when creating an object

If 'oid' is in the kwargs dict, return a known instance, else create a new instance.

commit( instance)
Commit an instance to the database.

If the instance is known, update the contents of the database, else insert the instance in the database.

query_generator( cls, query)
Yield all instances from

In addition, the following methods are available for simple database operations.

drop_table( class_name)
Remove the table for the class with name class_name.

PyORQ does not support schema evolution yet. You can use this method to remove the old table before modifying a persistent class definition

CAUTION. This may leave the database in an inconsistent state with dangling references.

empty_table( class_name)
Remove the contents of the table for the class with name class_name.

CAUTION. This may leave the database in an inconsistent state with dangling references.

5.2 pyorq.interface.postgresql_db -- for PostgreSQL

This module imports libpq from pyPgSQL

class postgresql_db( dsn=None, user=None, password=None, host=None, database=None, port=None, options=None, tty=None, client_encoding=None, unicode_results=None)

Create an interface to a PostgreSQL database.

All parameters are used to create the argument for the function libpq.PQconnectdb, which creates a connection.

dsn is a string of the form 'host:port:database:user:passwd:options:tty', that can be used as an alternative to the named arguments.

See Also:

pyPgSQL
For the Python interface to PostgreSQL by Billy G. Allie.

5.3 pyorq.interface.mysql_db -- for MySQL

This module imports _mysql, the low-level interface to MySQL, that is part of MySQL-Python.

class mysql_db( host=None, user=None, passwd=None, db=None, port=None)

Create an interface to a MySQL database.

All parameters are used to create the argument for the function _mysql.connect, which creates a connection.

See Also:

MySQL-Python
For the Python interface to MySQL by Andy Dustman.

5.4 pyorq.interface.sqlite_db -- for SQLite

This module imports _sqlite, the low-level interface to SQLite, that is provided by PySQLite.

class sqlite_db( database, mode=0755)
Create an interface to an SQLite database.

database (the filename of the database) and mode (the permissions for the file that constitutes the database) are passed to _sqlite.connect

See Also:

PySQLite
For the Python interface to SQLite by Michael Owens and Gerhard Haring.