Edgewall Software

Changes between Initial Version and Version 1 of TracDev/PluginDevelopment/ExtensionPoints/trac.db.api.IDatabaseConnector


Ignore:
Timestamp:
Jun 29, 2011, 11:05:14 PM (13 years ago)
Author:
psuter <petsuter@…>
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PluginDevelopment/ExtensionPoints/trac.db.api.IDatabaseConnector

    v1 v1  
     1== Extension Point : ''IDatabaseConnector'' ==
     2
     3||'''Interface'''||''IDatabaseConnector''||'''Since'''||[wiki:TracDev/ReleaseNotes/0.10#Improvedmodularity 0.10]||
     4||'''Module'''||''trac.db''||'''Source'''||[source:trunk/trac/db/api.py api.py]||
     5
     6
     7The ''IDatabaseConnector'' allows supporting different [DatabaseBackend database backends].
     8
     9== Purpose ==
     10
     11Trac 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.
     12
     13== Usage ==
     14
     15Implementing the interface follows the standard guidelines found in [wiki:TracDev/ComponentArchitecture] and of course [wiki:TracDev/PluginDevelopment].
     16
     17Typically, 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 [wiki:TracEnvironment#DatabaseConnectionStrings database connection string] selects the appropriate implementation to be used.
     18
     19Primarily, the implementation then provides [pep:0249 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.
     20
     21Implementations 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).
     22
     23== Examples ==
     24
     25Due to the complexity of implementing a full database backend, no simple example can be provided here.
     26
     27== Available Implementations ==
     28
     29* Official Trac connectors
     30  * SQLite: [source:trunk/trac/db/sqlite_backend.py trac.db.sqlite_backend.SQLiteConnector]
     31  * PostgreSQL: [source:trunk/trac/db/postgres_backend.py trac.db.postgres_backend.PostgreSQLConnector]
     32  * MySQL: [source:trunk/trac/db/mysql_backend.py trac.db.mysql_backend.MySQLConnector]
     33
     34== Additional Information and References ==
     35
     36 * [http://www.edgewall.org/docs/trac-trunk/epydoc/trac.db.api.IDatabaseConnector-class.html epydoc]
     37 * [http://www.edgewall.org/docs/trac-trunk/html/api/trac_db.html#trac.db.IDatabaseConnector API Reference]
     38 * DatabaseBackend
     39 * Tickets relating to:
     40  * [query:status=!closed&keywords=~sql sql]
     41  * [query:status=!closed&keywords=~database database]
     42  * [query:status=!closed&keywords=~db db]
     43  * [query:status=!closed&component=database+backend database backend] component
     44
     45 * About connectors for other databases
     46  * Oracle: #1874, th:ticket:5487
     47  * Ingres: #6235
     48  * Microsoft SQL Server: #329
     49  * Generic ODBC: comment:21:ticket:329
     50
     51 * About replacing the DB abstraction layer:
     52  * [DatabaseBackend#AlternativeIdeasforDatabaseIndependence alternative ideas]
     53  * with Django: #6339
     54  * with SqlAlchemy: [TracSqlAlchemy old plan], [browser:sandbox/Attic/sqlalchemy-ng retired branch]