| |
- __builtin__.object
-
- Db
- Factory
- SingletonFactory
- exceptions.Exception(exceptions.BaseException)
-
- DbError
class Db(__builtin__.object) |
|
Preside over Database connection and Database cursor.
example:
db = Db({'engine':'mysql', 'host':'db1', 'db':'books',
'user':'bookmgr', 'passwd':'mepassword', 'dictcursor':True })
Use db.factory.create() for reusing single database connections. |
|
Methods defined here:
- __del__(self)
- __init__(self, params)
- Db Class constructor
Params: engine, host, db, user, password, [ port ], [ dictcursor ]
- close(self)
- close_cursor(self)
- commit(self)
- connect(self, params)
- open_cursor(self)
- if 'dictcursor' in params:
self.cursor = self.connection.cursor(MySQLdb.cursors.DictCursor)
else:
self.cursor = self.connection.cursor()
- query(self, sql, from_trans=False, params=None)
- rollback(self)
- startTransaction(self)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- lastrowid
- rowcount
|
class Factory(__builtin__.object) |
| |
Methods defined here:
- create(self, **params)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class SingletonFactory(__builtin__.object) |
|
Factory class for providing unique Db class instances. |
|
Methods defined here:
- __init__(self)
- create(self, **params)
- Given the parameters:
engine, host, db, user, password, [ port ], [ dictcursor ]
Return a singleton instance of the Db class for those arguments.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |