# Class e.c.d.DBBackend(log.Loggable):

Part of elisa.core.db_backend View In Hierarchy

Python DB API 2.0 backend support.

In addition to DB API 2.0 support this class implements an SQL query filter, based on a set of rules (which remain to be defined...)

Components can alter the database by adding new tables in the schema. These new tables can only be accessed via raw SQL queries.

Unknown Field: todo | We need to define a set of rules that specify which component can alter/insert data in core_tables.

Line # | Kind | Name | Docs
--- | --- | --- | ---
79 | Method | __init__ | Connect to a db backend hosting the given database.
135 | Method | disconnect | Commit changes to the database and disconnect.
142 | Method | connect | Connect to the database, set `_db` instance variable.
151 | Method | reconnect | Disconnect and reconnect to the database.
158 | Method | save_changes | Commit changes to the database
173 | Method | insert | Execute an INSERT SQL query in the db backend
206 | Method | sql_execute | Execute a SQL query in the db backend
277 | Method | table_columns | Introspect given table and retrieve its column names in a cache

def __init__(self, **config):
overrides elisa.core.log.Loggable.__init__
Connect to a db backend hosting the given database.

Parameters | username | the user name to use to connect to the database (type: string or None if no username required by backend )
| password | the password to use to connect to the database (type: string or None if no password required by backend )
| hostname | the host name to connect to if the backend runs on a specific machine (type: string or None if no hostname required by backend )
Raises | DBBackendError | When no db backend has been specified or if it cannot be used.

def disconnect(self):
Commit changes to the database and disconnect.

def connect(self):
Connect to the database, set `_db` instance variable.

def reconnect(self):
Disconnect and reconnect to the database.

def save_changes(self):
Commit changes to the database

Raises | Exception | if the save has failed

def insert(self, sql_query, *params):
Execute an INSERT SQL query in the db backend and return the ID fo the row if AUTOINCREMENT is used

Parameters | sql_query | the SQL query data to execute (type: string )
Returns | (type: int )

def sql_execute(self, sql_query, *params, **kw):
Execute a SQL query in the db backend

Parameters | sql_query | the SQL query data to execute (type: string )
Returns | (type: `elisa.extern.db_row.DBRow` list )

def table_columns(self, table_name):

Introspect given table and retrieve its column names in a cache

The cache is global to the module, not DBBackend instance specific.

Parameters | table_name | name of the db table to introspect (type: string )
Returns | (type: string list )