| |
- Enumeration(Propertied)
-
- DriverName
- Propertied(object)
-
- DBDriver
- DriverCapabilities
class DBDriver(Propertied) |
|
Base class for database driver implementations
The DBDriver object is roughly analogous to the DB-API
module. In addition, it allows for resolving data types
from native driver-data-type-declarations to basicproperty/
basictypes/wxoo-style declarations.
Subclasses will generally provide a considerable number of
common query objects for use in introspection queries.
Each DBDriver subclass is known by a specifier string which
is a key in the DriverName enumeration. The specifier
strings are specified in the DBSpecifier object to select
the appropriate DBDriver run-time class.
Where appropriate, the DBDriver sub-class should
allow for querying to determine "system" databases,
such as ODBC named data sources.
See: getSystemSpecifiers() |
|
- Method resolution order:
- DBDriver
- Propertied
- object
Methods defined here:
- connect(self, specifier=None, share=1, **namedarguments)
- Connect using this driver to the specified database
specifier -- the DBSpecifier object encoding the connection
information to be used in establishing the connection
If specifier is None, then create a new DBSpecifier
using the named arguments as arguments to the DBSpecifier
constructor. Note: drivers with driver-specific specifier
classes may construct those specific classes instead of
the base DBSpecifier class.
If specifier is not None, but there are namedarguments,
the specifier will be cloned (copied) with the passed
namedarguments as parameters to the clone method. The
result will be that the named argument values will override
the specifier object's values.
share -- if true, the connection will be shared with any existing
connection which matches the calculated final specifier
- createSpecifier(self, **namedarguments)
- Create a new specifier object for this driver
namedarguments -- applied to the constructor of the
DBSpecifier
Note:
the drivername property will be set to our name
property's value
- establishConnection(self, fullSpecifier)
- Abstract Method: Connect using the fully specified specifier passed
fullSpecifier -- a specifier with all arguments unified
and ready to be connected. This specifier should
include everything required to do the actual
connection (including passwords or the like).
All sub-classes must override this method!
- getSystemSpecifiers(self, *arguments, **namedarguments)
- Customization Point: return list of system specifiers
For APIs which have system-registered data sources,
such as ODBC, this method should be overwritten to provide
system specifiers for the system-registered data sources.
- localToSQLType(self, source)
- Convert a local numeric data-type to an SQL string data-type
source -- the source specifier
returns an sql data-type for the given local SQL type, the
sub-class must provide the actual implementation.
- reconnect(self, connection)
- Reconnect the given DBConnection object
- sqlToBaseType(self, source)
- Convert given SQL data-type to a property-base-type
source -- the source specifier, an SQL identifier
returns a base-type suitable for use in basicproperty
properties to control the property's operation.
- sqlToDataType(self, source)
- Convert given SQL data-type to the desired data-type specifier
source -- the source specifier, an SQL identifier
returns a wxoo specifier or raises KeyError, only returns
the first-registered data-type, so sub-classes that want
to override the defaults need to prepend their dataTypeRegistry
to the dbdriver.DBDriver.dataTypeRegistry list.
- unifySpecifier(self, specifier, **namedarguments)
- Given specifier and named arguments create finalSpecifier
specifier -- DBSpecifer or None
named -- dictionary of attribute name to attribute value
See DBDriver.connect for discussion of the semantics
- wrapConnection(self, connection)
- Wrap the connection with a driver-aware connection object
Class methods defined here:
- copyErrorsFromModule(cls, source) from type
- Method to copy Error names from source to the driver class
Data and other attributes defined here:
- apilevel = <StringProperty 'apilevel'>
- DBAPI 2.0 apilevel value
- capabilities = <pytable.dbdriver.DriverCapabilities object at 0x01BA9A30>
- connectionProperties = ('dsn', 'host', 'user', 'password', 'database')
- connections = <WeakValueDictionaryProperty 'connections'>
- Mapping of specifier objects to live connections
The DBDriver retains weak references to all active
connections, to allow for connection sharing and/or
properly shutting down all connections on exit.
- dataTypeRegistry = [('float', 'float', <type 'float'>), ('float4', 'float', <type 'float'>), ('float8', 'float', <type 'float'>), ('int2', 'int', <type 'int'>), ('int4', 'int', <type 'int'>), ('int8', 'long', <type 'long'>), ('integer', 'int', <type 'int'>), ('bytea', 'str.long', <type 'str'>), ('char', 'str', <type 'str'>), ('text', 'str.long', <type 'str'>), ('varchar', 'str', <type 'str'>), ('bool', 'bool', 'basictypes.booleanfix.bool'), ('blob', 'str.locale', <type 'str'>), ('bpchar', 'str.locale', <type 'str'>), ('date', 'datetime', 'mx.DateTime.DateTimeType'), ('interval', 'datetimedelta', 'mx.DateTime.DateTimeDeltaType'), ('time', 'timeofday', 'basictypes.datemx_types.mxTimeOfDay'), ('timestamp', 'datetime', 'mx.DateTime.DateTimeType'), ('timestamptz', 'datetime', 'mx.DateTime.DateTimeType'), ('cash', 'decimal', <type 'int'>), ...]
- defaultConnectionClass = <ClassProperty 'defaultConnectionClass'>
- Default DBConnection sub-class to be used for this driver
- fileBased = 0
- friendlyName = <StringProperty 'friendlyName'>
- Friendly name of the DBDriver type
- localTypeRegistry = []
- name = <BasicProperty 'name'>
- DriverName enumeration identifying the driver in DBSpecifiers
- paramstyle = <StringProperty 'paramstyle'>
- DBAPI 2.0 parameter-style value
- queries = {}
- systemDBName = <StringProperty 'systemDBName'>
- Default name for driver's system database (for listDatabases connections)
- threadsafety = <IntegerProperty 'paramstyle'>
- DBAPI 2.0 threadsafety value XXX should be an enumeration!
- userDescription = ''
Methods inherited from Propertied:
- __init__(self, *arguments, **namedarguments)
- Propertied object initialisation, allows passing in initial values for properties by name
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01DF3890>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class DriverCapabilities(Propertied) |
|
Object storing set of driver capability declarations
At the moment, this is a fairly limited set of capability
declarations, mostly because the system only supports
a small number of features which are not considered
important enough to be implemented across all supported
databases. |
|
- Method resolution order:
- DriverCapabilities
- Propertied
- object
Data and other attributes defined here:
- inherits = <BooleanProperty 'inherits'>
- Whether we support PostgreSQL-style inheritance on tables
Inherits is an object-relational database feature that
provides (multiple) inheritance for database tables. If
it's available, we can model object hierarchies more
naturally. If not, we need to do (complex, slow) joins
across multiple tables to load base-class and sub-class
data.
- queryUnicode = <BooleanProperty 'queryUnicode'>
- Whether can accept Unicode for query strings
If this is false, then sqlquery needs to translate queries into
strings, which it will do using utf-8 encodings.
- serial = <BooleanProperty 'serial'>
- Whether we have native support for serial datatype
If the serial datatype is not supported, we'll have to
generate code to create a sequence, track the name of
that sequence and potentially rewrite the defaultValue
field of the schema.
Methods inherited from Propertied:
- __init__(self, *arguments, **namedarguments)
- Propertied object initialisation, allows passing in initial values for properties by name
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01D86030>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class DriverName(Enumeration) |
|
Specifier for a driver-name enumeration value |
|
- Method resolution order:
- DriverName
- Enumeration
- Propertied
- object
Data and other attributes defined here:
- datatype = 'enumeration.DriverName'
- set = {u'MkSQL': EnumerationChoice( name=u'MkSQL', val...er.MyDriver', friendlyName=u'MySQL via MySQLdb')}
Methods inherited from Enumeration:
- __cmp__(self, other)
- Compare this value to another value
- __init__(self, name='', *arguments, **named)
- __repr__(self)
- Return a code-like representation of this object
- __str__(self)
- Return the enumeration value as a name
- choice(self)
- Get the choice object associated with this value or None
- value(self)
- Get the value associated with this choice
Class methods inherited from Enumeration:
- allInstances(cls) from type
- Return cls instances for each of this class's set
- check(cls, value) from type
- Check whether value is of cls type, and has the same set
- coerce(cls, value) from type
- Coerce a value into an Enumeration value
Accepted types:
Enumeration objects
integers/longs
([name,name,name],remainder) tuples
[name,name,name,value] lists (values are |'d together)
- fromValue(cls, value) from type
- Create from an integer value
- parse(cls, value) from type
- Create from a string value
Possible formats:
"coreName"
"23"
"friendlyName"
Data and other attributes inherited from Enumeration:
- dataType = 'enumeration'
- name = <BasicProperty 'name'>
- Data-value choice within one of our sets
Methods inherited from Propertied:
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01D86E30>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
| |