Package elisa :: Package core :: Module db_backend :: Class DBBackend
[hide private]
[frames] | no frames]

Class DBBackend

source code


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.


To Do: We need to define a set of rules that specify which component can alter/insert data in core_tables.

Instance Methods [hide private]
 
__init__(self, **config)
Connect to a db backend hosting the given database.
source code
 
disconnect(self)
Commit changes to the database and disconnect.
source code
 
connect(self)
Connect to the database, set _db instance variable.
source code
 
reconnect(self)
Disconnect and reconnect to the database.
source code
 
save_changes(self)
Commit changes to the database
source code
int
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
source code
elisa.extern.db_row.DBRow list
sql_execute(self, sql_query, *params, **kw)
Execute a SQL query in the db backend
source code
 
_query(self, request, *params, **keywords) source code
 
_fix_params(self, params) source code
string list
table_columns(self, table_name)
Introspect given table and retrieve its column names in a cache
source code

Inherited from extern.log.log.Loggable: debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]

Inherited from extern.log.log.Loggable: logCategory

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **config)
(Constructor)

source code 
Connect to a db backend hosting the given database.
Parameters:
  • username (string or None if no username required by backend) - the user name to use to connect to the database
  • password (string or None if no password required by backend) - the password to use to connect to the database
  • hostname (string or None if no hostname required by backend) - the host name to connect to if the backend runs on a specific machine
Raises:
  • DBBackendError - When no db backend has been specified or if it cannot be used.
Overrides: log.Loggable.__init__

save_changes(self)

source code 
Commit changes to the database
Raises:
  • Exception - if the save has failed

insert(self, sql_query, *params)

source code 
Execute an INSERT SQL query in the db backend and return the ID fo the row if AUTOINCREMENT is used
Parameters:
  • sql_query (string) - the SQL query data to execute
Returns: int

sql_execute(self, sql_query, *params, **kw)

source code 
Execute a SQL query in the db backend
Parameters:
  • sql_query (string) - the SQL query data to execute
Returns: elisa.extern.db_row.DBRow list

table_columns(self, table_name)

source code 

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 (string) - name of the db table to introspect
Returns: string list