Package grizzled :: Package db :: Module dummydb :: Class DummyDriver
[hide private]
[frames] | no frames]

Class DummyDriver

source code

   object --+    
            |    
base.DBDriver --+
                |
               DummyDriver

Dummy database driver, for testing.
Instance Methods [hide private]
 
get_import(self)
Get a bound import for the underlying DB API module.
source code
str
get_display_name(self)
Get the driver's name, for display.
source code
object
do_connect(self, host='localhost', port=None, user='', password='', database='default')
Connect to the actual underlying database, using the driver.
source code

Inherited from base.DBDriver: connect, get_index_metadata, get_rdbms_metadata, get_table_metadata, get_tables

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from base.DBDriver: display_name

Inherited from object: __class__

Method Details [hide private]

get_import(self)

source code 

Get a bound import for the underlying DB API module. All subclasses must provide an implementation of this method. Here's an example, assuming the real underlying Python DB API module is 'foosql':

def get_import(self):
    import foosql
    return foosql
Returns:
a bound module
Overrides: base.DBDriver.get_import
(inherited documentation)

get_display_name(self)

source code 
Get the driver's name, for display. The returned name ought to be a reasonable identifier for the database (e.g., 'SQL Server', 'MySQL'). All subclasses must provide an implementation of this method.
Returns: str
the driver's displayable name
Overrides: base.DBDriver.get_display_name
(inherited documentation)

do_connect(self, host='localhost', port=None, user='', password='', database='default')

source code 

Connect to the actual underlying database, using the driver. Subclasses must provide an implementation of this method. The method must return the result of the real DB API implementation's connect() method. For instance:

def do_connect():
    dbi = self.get_import()
    return dbi.connect(host=host, user=user, passwd=password,
                       database=database)

There is no need to catch exceptions; the DBDriver class's connect() method handles that.

Parameters:
  • host - the host where the database lives
  • port - the TCP port to use when connecting
  • user - the user to use when connecting
  • password - the password to use when connecting
  • database - the name of the database to which to connect
Returns: object
a DB API-compliant object representing the open database
Raises:
Overrides: base.DBDriver.do_connect
(inherited documentation)