Edgewall Software

Extension Point : IDatabaseConnector

InterfaceIDatabaseConnectorSince0.10
Moduletrac.dbSourceapi.py

The IDatabaseConnector allows supporting different database backends.

Purpose

Trac provides generic database abstraction layer, allowing extensible support for different database backends. This allows Trac to be used with either SQLite, MySQL, PostgreSQL or any other database for which a connector is available.

Usage

Implementing the interface follows the standard guidelines found in TracDev/ComponentArchitecture and of course TracDev/PluginDevelopment.

Typically, an implementation checks if any required binding libraries are available when loaded. On failure, an error can be indicated when Trac queries the supported schemes. The schema of the database connection string selects the appropriate implementation to be used.

Primarily, the implementation then provides Python DB API 2.0 connection and cursor objects for that connection string. Typically a ConnectionWrapper is used to wrap the connection object of the specific db library.

Implementations also initialize and backup a database, and generate implementation specific DDL and SQL for poorly standardized features (like type casting, string concatenation, pattern matching, accessing the last row id).

Examples

Due to the complexity of implementing a full database backend, no simple example can be provided here.

Available Implementations

Additional Information and References

Last modified 7 years ago Last modified on Jun 30, 2011, 8:36:42 AM
Note: See TracWiki for help on using the wiki.