| |
- PostgresDriver(DBDriver)
-
- PGDriver
class PGDriver(PostgresDriver) |
|
PyPgSQL PostgreSQL database driver
This is the most commonly used driver for the
PyTable module, and as such has had the most testing
and debugging. It provides basically all features,
which are supported by PyTable, and is available
under a Python-CNRI-style license. |
|
- Method resolution order:
- PGDriver
- PostgresDriver
- DBDriver
- Propertied
- object
Class methods defined here:
- getLastOID(cls, cursor) from type
- Given a cursor, return last-inserted OID value
This implementation overrides the base implementation to
support the (non-standard) use of oidValue instead of
lastrowid to store the OID value.
Data and other attributes defined here:
- DataError = <class libpq.DataError at 0x0199B3F0>
- DatabaseError = <class libpq.DatabaseError at 0x0199B3C0>
- Error = <class libpq.Error at 0x0199B360>
- IntegrityError = <class libpq.IntegrityError at 0x0199B450>
- InterfaceError = <class libpq.InterfaceError at 0x0199B390>
- InternalError = <class libpq.InternalError at 0x0199B480>
- NotSupportedError = <class libpq.NotSupportedError at 0x0199B510>
- OperationalError = <class libpq.OperationalError at 0x0199B420>
- ProgrammingError = <class libpq.ProgrammingError at 0x0199B4B0>
- Warning = <class libpq.Warning at 0x0199B330>
- apilevel = <StringProperty 'apilevel'>
- DBAPI 2.0 apilevel value
- baseModule = <module 'pyPgSQL.PgSQL' from 'p:\sharedinstall\pyPgSQL\PgSQL.pyc'>
- localTypeRegistry = [(702, 'abstime'), (1033, 'aclitem'), (20, 'bigint'), (2, 'blob'), (16, 'bool'), (603, 'box'), (1042, 'bpchar'), (17, 'bytea'), (790, 'cash'), (18, 'char'), (29, 'cid'), (650, 'cidr'), (718, 'circle'), (1082, 'date'), (701, 'float'), (700, 'float4'), (701, 'float8'), (869, 'inet'), (21, 'int2'), (22, 'int2vector'), ...]
- name = 'weakref'
- paramstyle = <StringProperty 'paramstyle'>
- DBAPI 2.0 parameter-style value
- threadsafety = <IntegerProperty 'paramstyle'>
- DBAPI 2.0 threadsafety value XXX should be an enumeration!
- userDescription = 'PostgreSQL database driver (via PyPgSQL)\n\nProvid...postgresql.org/\n\thttp://pypgsql.sourceforge.net/\n'
Methods inherited from PostgresDriver:
- __getattr__(self, key)
- Search for an action-script of the given name in actionScripts
- establishConnection(self, fullSpecifier)
- Connect using the fully specified specifier
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!
- getInsertedRow(self, cursor, tableName, fields=None)
- Select fields for the last insert on cursor
cursor -- pytable.dbcursor instance which has had
an insert query run as its last query.
In this implementation, the cursor.cursor.lastrowid
attribute will be used to specify the row to
retrieve. Note: it is possible for this field
not to be available if the user has explicitly
suppressed oid generation for the table.
tableName -- name of the table to be selected from
fields -- sequence of field names to select from the
table, uses * by default
returns cursor for the given selection query, note
that in error cases this may not have any records, and
that there may be errors raised if the table or fields
given are not part of the database.
Note:
This method implements the driver-specific mechanism
for retrieving the results of the last insertion to the
database. This is an SQL problem area where it is
generally difficult to determine what particular record
has been inserted by giving query. Each database tends
to have its own method for doing such a query,
reporting the data required to do to query, etc.
Data and other attributes inherited from PostgresDriver:
- capabilities = <pytable.dbdriver.DriverCapabilities object at 0x01806B70>
- 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'>), ...]
- queries = {'attrDefault': <pytable._postgresql.tableactions.AttributeDefaultValue object at 0x01685350>, 'foreignConstraints': <pytable._postgresql.tableactions.ForeignConstraints object at 0x01685D50>, 'listDatabases': <pytable._postgresql.tableactions.ListDatabases object at 0x01685170>, 'listDatatypes': <pytable._postgresql.tableactions.ListDatatypes object at 0x01685F30>, 'listIndices': <pytable._postgresql.tableactions.ListIndices object at 0x016855B0>, 'listTables': <pytable._postgresql.tableactions.ListTables object at 0x01685D30>, 'tableStructure': <pytable._postgresql.tableactions.TableStructure object at 0x016852B0>}
- systemDBName = <StringProperty 'systemDBName'>
- Default name for driver's system database (for listDatabases connections)
Methods inherited from DBDriver:
- 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
- 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 inherited from DBDriver:
- copyErrorsFromModule(cls, source) from type
- Method to copy Error names from source to the driver class
Data and other attributes inherited from DBDriver:
- 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.
- defaultConnectionClass = <ClassProperty 'defaultConnectionClass'>
- Default DBConnection sub-class to be used for this driver
- fileBased = 0
- friendlyName = <StringProperty 'friendlyName'>
- Friendly name of the DBDriver type
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 0x01AFBB50>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
| |