Package wsatools :: Package DbConnect :: Module DbSession :: Class DbSession
[hide private]

Class DbSession

source code


An interface to our database. Manages the mxODBC connection, and provides a set of wrappers to common SQL statements.


Note: Test database connections get read-write user access by default.

Nested Classes [hide private]
    Errors & Exceptions
  CatalogueServerError
An error generated by a command run directly on the catalogue server.
  DisconnectError
Exception thrown if a programmer tries to access a database connection that is closed, to either attempt close it or commit/rollback transactions.
Instance Methods [hide private]
 
__init__(self, database='ramses1.WSA', autoCommit=False, isTrialRun=False, userName='ldservro', isPersistent=True, cli=None)
Makes connection to the requested database.
source code
 
__del__(self)
Closes database connection, committing uncommited transactions.
source code
str
__str__(self)
Returns: Database path.
source code
 
addColumn(self, tableName, colName, dataType, defaultStr=None, notNull=True, constraint=None)
Adds a column to a table in the database.
source code
bool
addIndex(self, indexSchema, ignoreNS=False, releasedOnly=False, usingDefaultFG=False)
Adds an index to a specified table.
source code
 
alterColumn(self, tableName, colName, dataType, defaultStr=None, notNull=True, constraint=None)
Alter a column of a table in the database.
source code
 
checkConstraints(self, tableName)
Checks the database constraints on specified table.
source code
 
checkSchema(self, tableSchema, releasedOnly=False)
Compares the given table schema as described in the .sql files to the actual database schema to spot inconsistencies.
source code
 
commitTransaction(self)
Manually commit a transaction if auto-commit is switched off.
source code
int
copyIntoTable(self, destinationTable, sourceTable, columns='*', where='')
Copy a selection of rows from one table into another.
source code
int
copyTable(self, sourceTable, tableSchema, columns='*', where='', fileGroup='', attachForeignKeys=True)
Create a new table from the selected contents of another table.
source code
bool
createObjects(self, objSchema, overWrite=False, ignoreNS=False, releasedOnly=False, haltOnError=True)
Create new database objects using the ordered list of object schema definitions provided from Schema methods.
source code
 
createStatistics(self, tables)
Creates database column statistics for given tables.
source code
bool
createTable(self, tableSchema, dbSchema=[], overWrite=False)
Create a new database table using the schema provided from Schema.parseTables(), all constraints that reference this table found in the given schema list will be applied.
source code
 
createUser(self, userName, password)
Creates a new user account on the current server and grants it read-only access to the current database.
source code
int
delete(self, tableName, whereStr='')
Deletes rows from a database table (to delete an entire table use truncate() instead) based on a flexible SQL WHERE clause.
source code
int
deleteRows(self, tableName, rowIndexList=[])
Deletes selected rows from a database table (to delete an entire table use truncate() instead).
source code
 
dropColumn(self, tableName, colName)
Removes a column from a table in the database.
source code
 
dropObjects(self, objSchema)
Drop database objects defined in a list of database Schema objects.
source code
 
dropTable(self, tableSchema, dbSchema)
Drops a table from the database, first removing any foreign key constraints that reference the table.
source code
 
enableDirtyRead(self)
Allows you to read from tables that are being written to and hence are presently locked.
source code
bool
existsTable(self, tableName)
Returns: True, if table with name given in tableName parameter exists in current database.
source code
 
freeProcCache(self)
Calls DBCC FREEPROCCACHE.
source code
str
getBestVolume(self)
Returns: The volume on the catalogue server with the most free space, e.g.
source code
 
goOffline(self)
Temporarily drop the database connection, whilst keeping the DbSession object alive.
source code
 
grantAccess(self, userName)
Grants access to a given user to access the database.
source code
int
insertData(self, tableName, rowData, enforcePKC=False)
Insert some data into the database.
source code
list
query(self, selectStr, fromStr, whereStr='', groupBy='', orderBy='', firstOnly=False, default=None, ResultsTuple=None, forceOneProc=False, forcePrOrder=False)
Wrapper function to perform a general select-from-where query.
source code
bool
queryAllowsNulls(self, queryTable, columns)
Determine whether the table contains nullable columns.
source code
scalar
queryAttrMax(self, attrs, table, where='')
Wrapper to just query the maximum value of the given attributes.
source code
list(str)
queryColumnNames(self, tableName)
Queries database to produce a list of column names in the table.
source code
dict(str:str)
queryDataTypes(self, table)
Queries database to produce a dictionary of data-types for each column.
source code
bool
queryEntriesExist(self, table, where='', pk='')
Queries database to determine if any rows exist in the given table that satisfy the WHERE clause.
source code
int or list(tuple)
queryNumRows(self, tableName, whereStr='', groupBy='', distinctAttr='')
Wrapper to just query the number of rows in a given table.
source code
int
queryRowSize(self, queryTable)
Determine the row size of the given table or the select query result.
source code
 
renameTable(self, oldName, newName)
Rename the given database table.
source code
 
rollbackTransaction(self)
Rollback a transaction.
source code
list(str)
runOnServer(self, cmd, isTrialRunSafe=False)
Runs a command directly on the database server.
source code
 
sharePath(self, fileName='')
Returns the path to the given file in the catalogue server's share directory for outgests and ingests.
source code
 
shrinkTempDb(self)
Shrinks tempdb and its log files.
source code
str
tablePath(self, tableName, ownerName='dbo')
Full database path to the given table.
source code
 
testSharePath(self)
Checks to see if the share path for this database is active.
source code
int
truncate(self, tableName)
Wipes a database table - use with care!
source code
str
uncPath(self, filePathName)
Converts the given catalogue server local path into a UNC path.
source code
int
update(self, tableName, entryList, where='', fromTables='')
Update specific entries in database table rows specified with a flexible SQL WHERE clause.
source code
int
updateEntries(self, tableName, entryList, rowIndexList=[])
Update specific entries in a database table row.
source code
 
updateStatistics(self)
Updates database index statistics.
source code
 
_closeConnection(self)
Closes a database cursor and connection.
source code
str
_createWhereStr(self, rowIndexList)
Converts a list of tuple pairs of the form (attribute name, value) into a correctly formatted SQL WHERE clause.
source code
list(tuple) or int
_executeScript(self, script, parameters=None, wantResult=False, wantAll=True, wantRowCount=False)
Send any SQL script to the server to execute.
source code
Cursor
_getCursor(self)
Method to obtain cursor for current DbSession.
source code
 
_openConnection(self)
Opens a database connection and initiates the cursor.
source code
 
_raiseWithScript(self, err, script)
Appends the SQL script to an mxODBC exception and raises it.
source code
tuple(str, str, str)
_splitTablePath(self, tablePath)
Decomposes a full table path to its individual components.
source code
str
_sqlString(self, value)
Returns: An SQL string of the correct format for the data type.
source code

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

Class Variables [hide private]
  _dbConnections = {}
Session manager.
  _isLogReq = {}
Dictionary of flags to indicate a database has been modified, referenced by database name.
  _numSessions = {}
Counter to track number of sessions per database.
  sysc = SystemConstants()
System constants for this DbSession.
  database = 'WSA'
Name of the database to connect to this session.
  isLoadDb = True
Is this a database connection to the load database?
  isRealRun = True
Is this a database connection to the load database by the operator?
  isTrialRun = False
For statements that modify the database print SQL instead of executing.
  server = 'ramses1'
Server that hosts the database to connect to.
  userName = 'ldservro'
Username with which to use for this session's database connection.
  _autoCommit = False
Automatically commit transactions, minimally logged so faster.
  _fixedCopyBug = False
Has workaround for multiple copies been applied?
  _isDeadlocked = False
Database is currently deadlocked?
  _isDirty = False
Is this connection performing dirty reads?
  _isPersistent = True
Persistently reconnect if broken?
Instance Variables [hide private]
  _dbSessionKey = None
Specifies a unique database connection
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, database='ramses1.WSA', autoCommit=False, isTrialRun=False, userName='ldservro', isPersistent=True, cli=None)
(Constructor)

source code 

Makes connection to the requested database.

Parameters:
  • database (str) - Name of the database to connect to, prepend with server name if not load server. For example, "amenhotep.TWOMASS".
  • autoCommit (bool) - If True, every transaction is instantly committed. This speeds up transactions through minimal logging.
  • isTrialRun (bool) - If True, do not perform database modifications, just print the SQL statement to the terminal.
  • userName (str) - Optionally override default database username.
  • isPersistent (bool) - If True then persistent reconnects are made to the database if an already open connection is dropped. Only applied in autoCommit=True mode.
  • cli (CLI.CLI) - Optionally initialise using the settings supplied by the command-line options.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Returns: str
Database path.
Overrides: object.__str__

addColumn(self, tableName, colName, dataType, defaultStr=None, notNull=True, constraint=None)

source code 

Adds a column to a table in the database.

Parameters:
  • tableName (str) - Name of the table.
  • colName (str) - Name of the new column.
  • dataType (str) - SQL data type of the new attribute.
  • defaultStr (str) - Optional default value, in the form of an SQL string e.g. "'none'" or "0".
  • notNull (bool) - If True, column disallows null values.
  • constraint (str) - Optional constraint name. Defaults to tableName + colName + '_cons'.

addIndex(self, indexSchema, ignoreNS=False, releasedOnly=False, usingDefaultFG=False)

source code 

Adds an index to a specified table.

Parameters:
  • indexSchema (Schema.Index) - Object describing the schema of the index to add.
  • ignoreNS (bool) - If True, upon a "no such" error message reporting non-existent tables, attributes etc. log the message and continue, with False return state (no object created).
  • releasedOnly (bool) - If True, only create the object if it is to be released (i.e. upper case CREATE statements).
  • usingDefaultFG (bool) - If False, use the file group "Indices_FG".
Returns: bool
True, if index has been created.

alterColumn(self, tableName, colName, dataType, defaultStr=None, notNull=True, constraint=None)

source code 

Alter a column of a table in the database.

Parameters:
  • tableName (str) - Name of the table.
  • colName (str) - Name of the existing column.
  • dataType (str) - Desired SQL data type for the column.
  • defaultStr (str) - Optional default value, in the form of an SQL string e.g. "'none'" or "0".
  • notNull (bool) - If True, column disallows null values.
  • constraint (str) - Optional constraint name. Defaults to tableName + colName + '_cons'.

To Do: Should become more schema driven together with addColumn().

checkConstraints(self, tableName)

source code 

Checks the database constraints on specified table. Logs any constraint violations and throws an exception if any are detected.

Parameters:
  • tableName (str) - Name of the table.

checkSchema(self, tableSchema, releasedOnly=False)

source code 

Compares the given table schema as described in the .sql files to the actual database schema to spot inconsistencies. If there any problems a Schema.MismatchError exception is thrown.

Parameters:
  • tableSchema (list(Schema.Table)) - Schema of tables to check as provided by Schema.parseTables().
  • releasedOnly (bool) - If True, only check released database tables.

copyIntoTable(self, destinationTable, sourceTable, columns='*', where='')

source code 

Copy a selection of rows from one table into another.

Parameters:
  • destinationTable (str) - Table to copy rows into.
  • sourceTable (str or Join) - Table to copy from, or a Join object of several tables.
  • columns (str) - Optional select a subset of columns, as a comma-separated list.
  • where (str) - Optional SQL where clause defining the selection of rows to copy.
Returns: int
Number of rows copied.

Note: This command is heavily transaction logged.

copyTable(self, sourceTable, tableSchema, columns='*', where='', fileGroup='', attachForeignKeys=True)

source code 

Create a new table from the selected contents of another table.

Parameters:
  • sourceTable (str or Join) - Table to copy from, or a Join object of several tables.
  • tableSchema (Schema.Table) - Schema of table to copy rows into that will be created in this database.
  • columns (str) - Optional select a subset of columns, as a comma-separated list.
  • where (str) - Optional SQL where clause defining the selection of rows to copy.
  • fileGroup (str) - Optionally supply a different file group to create the new table on other than the default.
  • attachForeignKeys (bool) - If True, foreign key constraints are attached to the new table.
Returns: int
Number of rows copied.
Notes:
  • This command should be minimally logged.
  • This method relies on Microsoft T-SQL, rather than standard SQL.
  • Changing file-group is an experimental untested feature so far.

createObjects(self, objSchema, overWrite=False, ignoreNS=False, releasedOnly=False, haltOnError=True)

source code 

Create new database objects using the ordered list of object schema definitions provided from Schema methods. Tables are created with primary key constraints but no foreign key constraints, use createTable() instead if they are required.

Parameters:
  • objSchema (list(Schema._Schema)) - An ordered list of objects derived from Schema._Schema.
  • overWrite (bool) - If True, allow pre-existing database objects with the same name to be overwritten.
  • ignoreNS (bool) - If True, do not throw an exception if an object could not be created because some other object in the database does not exist. The function will return False - object could not be created, but no warning message will be displayed.
  • releasedOnly (bool) - If True, only create the object if it is to be released (i.e. upper case CREATE statements).
  • haltOnError (bool) - If True, raise an exception as soon as it occurs otherwise continue with the next object and raise an error at the end.
Returns: bool
True, if all objects created successfully.

createStatistics(self, tables)

source code 

Creates database column statistics for given tables.

Parameters:
  • tables (list(Schema.Table)) - List of table schema.

createTable(self, tableSchema, dbSchema=[], overWrite=False)

source code 

Create a new database table using the schema provided from Schema.parseTables(), all constraints that reference this table found in the given schema list will be applied.

Parameters:
  • tableSchema (Schema.Table) - Parsed schema describing the table that is to be created.
  • dbSchema (list(Schema.Table)) - Schemas for every table in the database that may have a foreign key constraint that references the table to be created.
  • overWrite (bool) - If True, allow current db table to be overwritten.
Returns: bool
True, if table really was created.

createUser(self, userName, password)

source code 

Creates a new user account on the current server and grants it read-only access to the current database.

Parameters:
  • userName (str) - User name for new account.
  • password (str) - Password for user name.

delete(self, tableName, whereStr='')

source code 

Deletes rows from a database table (to delete an entire table use truncate() instead) based on a flexible SQL WHERE clause.

Parameters:
  • tableName (str) - Name of the database table.
  • whereStr (str) - SQL WHERE clause (without the "WHERE").
Returns: int
Number of rows deleted.

deleteRows(self, tableName, rowIndexList=[])

source code 

Deletes selected rows from a database table (to delete an entire table use truncate() instead).

Parameters:
  • tableName (str) - Name of the database table.
  • rowIndexList (list(tuple(str, object))) - List of specific rows to delete, in the form (attrName, PyValue), e.g. [("multiframeId", 101)], all rows are deleted otherwise. If PyValue is a list then executemany is invoked.
Returns: int
Number of rows deleted.

dropColumn(self, tableName, colName)

source code 

Removes a column from a table in the database.

Parameters:
  • tableName (str) - Name of the table.
  • colName (str) - Name of the new column.

dropObjects(self, objSchema)

source code 

Drop database objects defined in a list of database Schema objects. Tables cannot be dropped if referenced by foreign key constraints, in this case use dropTable().

Parameters:
  • objSchema (list(Schema._Schema)) - An ordered list of objects derived from Schema._Schema.

dropTable(self, tableSchema, dbSchema)

source code 

Drops a table from the database, first removing any foreign key constraints that reference the table.

Parameters:
  • tableSchema (Schema.Table) - Parsed schema describing the table that is to be created.
  • dbSchema (list(Schema.Table)) - Schemas for every table in the database that may have a foreign key constraint that references the table to be created.

enableDirtyRead(self)

source code 

Allows you to read from tables that are being written to and hence are presently locked. Warning, use at your own risk!

existsTable(self, tableName)

source code 
Returns: bool
True, if table with name given in tableName parameter exists in current database.

getBestVolume(self)

source code 
Returns: str
The volume on the catalogue server with the most free space, e.g. G:\.

goOffline(self)

source code 

Temporarily drop the database connection, whilst keeping the DbSession object alive. When an attempt to access the database is next made, the DbSession will automatically try reconnect to the database.

grantAccess(self, userName)

source code 

Grants access to a given user to access the database.

Parameters:
  • userName (str) - User name that will have permissions set.

insertData(self, tableName, rowData, enforcePKC=False)

source code 

Insert some data into the database.

Parameters:
  • tableName (str) - Name of the database table.
  • rowData (sequence) - Sequence of unformatted data values for each column, e.g. ("astring", 0, 5.4).
  • enforcePKC (bool) - If True, throw an exception if row already exists, otherwise just log a warning.
Returns: int
Number of rows inserted (either 1 or 0).

query(self, selectStr, fromStr, whereStr='', groupBy='', orderBy='', firstOnly=False, default=None, ResultsTuple=None, forceOneProc=False, forcePrOrder=False)

source code 

Wrapper function to perform a general select-from-where query.

Parameters:
  • selectStr (str) - SQL SELECT string; comma-separated column names.
  • fromStr (str or Join) - SQL FROM string; single table name or Join object.
  • whereStr (str) - Optional SQL WHERE clause.
  • groupBy (str) - Optional SQL GROUP BY string.
  • orderBy (str) - Optional SQL ORDER BY string.
  • firstOnly (bool) - If True, just return the first entry in result set.
  • default (object) - Value to return if querying first entry and no entries found.
  • ResultsTuple (type) - Convert results to this specific namedtuple type.
  • forceOneProc (bool) - Force query to execute only on a single-processor (disable parallelism).
  • forcePrOrder (bool) - Force where clause predicates to be evaluated in the stated order.
Returns: list
List of tuples (or scalars if only one attribute selected) containing values for every attribute of every entry. The tuples will be namedtuples of the database column names, if possible - i.e. no duplicate column names or functions without aliases. If firstOnly then a scalar or a tuple (or namedtuple) is returned.

To Do: Either replace arguments with one SelectSQL argument or: replicate SelectSQL.__init__() interface: selectStr becomes select, fromStr becomes table, whereStr becomes where - then remove code duplication by creating an SelectSQL object here.

queryAllowsNulls(self, queryTable, columns)

source code 

Determine whether the table contains nullable columns.

Parameters:
  • queryTable (str) - Name of table to query.
  • columns (sequence(str)) - Sequence of columns to check.
Returns: bool
True if any of the columns are nullable.

queryAttrMax(self, attrs, table, where='')

source code 

Wrapper to just query the maximum value of the given attributes.

Parameters:
  • attrs (str) - Name of the attributes in the database (comma-separated).
  • table (str or Join) - Table with the attributes.
  • where (str) - Optional SQL WHERE clause.
Returns: scalar
Maximum value of that attribute. Defaults to None.

queryColumnNames(self, tableName)

source code 

Queries database to produce a list of column names in the table.

Parameters:
  • tableName (str) - Name of the database table.
Returns: list(str)
A list of the column names, in order, from the given table.

queryDataTypes(self, table)

source code 

Queries database to produce a dictionary of data-types for each column.

Parameters:
  • table (str) - Name of the database table, with optional full-path.
Returns: dict(str:str)
A dictionary where the keywords are the column names and the values are the data-types of those columns.

queryEntriesExist(self, table, where='', pk='')

source code 

Queries database to determine if any rows exist in the given table that satisfy the WHERE clause.

Parameters:
  • table (str or Join) - Table to query. A single table name or a Join object.
  • where (str) - Optional WHERE clause.
  • pk (str) - Optionally supply primary key to speed up query. Not required if table is a Join.
Returns: bool
True, if there are any rows in the table that satisfy the WHERE clause.

queryNumRows(self, tableName, whereStr='', groupBy='', distinctAttr='')

source code 

Wrapper to just query the number of rows in a given table. Will also return the total count for a "SELECT count(*) ... GROUP BY"-type query, if the "GROUP BY" is specified in the whereStr keyword, rather than the groupBy keyword.

Parameters:
  • tableName (str) - Table to query.
  • whereStr (str) - WHERE string, optional where clause.
  • groupBy (str) - Specify a comma-separated list of columns in which to group counts by.
  • distinctAttr (str) - With distinct values of this attribute.
Returns: int or list(tuple)
Number of rows, if no groupBy keyword, otherwise a list of the groupBy attribute values in ascending order with counts.

queryRowSize(self, queryTable)

source code 

Determine the row size of the given table or the select query result.

Parameters:
  • queryTable (str or SelectSQL) - Either just a single table name or a select query.
Returns: int
Size in bytes of a row.

renameTable(self, oldName, newName)

source code 

Rename the given database table.

Parameters:
  • oldName (str) - Existing database table name.
  • newName (str) - Name to give to the database table.

rollbackTransaction(self)

source code 

Rollback a transaction.

Note: Only applies if auto-commit is switched off.

runOnServer(self, cmd, isTrialRunSafe=False)

source code 

Runs a command directly on the database server.

Parameters:
  • cmd (str) - Command-line command to run on the database server.
  • isTrialRunSafe (bool) - Can this command be run in trial-run mode?
Returns: list(str)
A result set.

sharePath(self, fileName='')

source code 

Returns the path to the given file in the catalogue server's share directory for outgests and ingests.

Parameters:
  • fileName (str) - Name of the file on the share.

To Do: Deprecate!

tablePath(self, tableName, ownerName='dbo')

source code 

Full database path to the given table.

Parameters:
  • tableName (str) - Name of table.
  • ownerName (str) - Optionally specify a different table owner name than the database owner.
Returns: str
Full path to database table, e.g. ahmose.WSA.dbo.tableName.

testSharePath(self)

source code 

Checks to see if the share path for this database is active. Raises a SystemExit if there are problems.

truncate(self, tableName)

source code 

Wipes a database table - use with care!

Parameters:
  • tableName (str) - Name of database table to wipe.
Returns: int
Number of rows deleted from table.
To Do:
  • Deprecate in favour of delete() without where clause?
  • Always call truncate over delete from if not where clause, with the addition of a drop and add constraints?

uncPath(self, filePathName)

source code 

Converts the given catalogue server local path into a UNC path.

Parameters:
  • filePathName (str) - Catalogue server local path.
Returns: str
Catalogue server UNC path.

update(self, tableName, entryList, where='', fromTables='')

source code 

Update specific entries in database table rows specified with a flexible SQL WHERE clause.

Parameters:
  • tableName (str) - Name of the database table.
  • entryList (list(tuple(str, str)) or str) - List entries to update, in the form (attrName, SQLvalue) with value as an SQL formatted string, as defined by DbSession._sqlString(), e.g. [("skyID", -9999), ("raMoon", "1.01"), ("trackSys", "'J2000'")]. (NB: this may also be an explicit string for the SQL SET statement e.g. "trackSys='J2000'")
  • where (str) - SQL WHERE clause (without the "WHERE").
  • fromTables (str or Join) - Optional source to update from (SQL FROM syntax), single table name or Join object.
Returns: int
Number of rows updated.

updateEntries(self, tableName, entryList, rowIndexList=[])

source code 

Update specific entries in a database table row.

Parameters:
  • tableName (str) - Name of the database table.
  • entryList (list(tuple(str, str)) or str) - List entries to update, in the form (attrName, SQLvalue) with value as an SQL formatted string, as defined by DbSession._sqlString(), e.g. [("skyID", -9999), ("raMoon", "1.01"), ("trackSys", "'J2000'")]. (NB: this may also be an explicit string for the SQL SET statement e.g. "trackSys='J2000'")
  • rowIndexList (list(tuple(str, object))) - List of specific rows to update, in the form (attrName, PyValue), e.g. [("multiframeID", 101)], all rows are updated otherwise. If PyValue is a list then executemany is invoked.
Returns: int
Number of rows updated.

_createWhereStr(self, rowIndexList)

source code 

Converts a list of tuple pairs of the form (attribute name, value) into a correctly formatted SQL WHERE clause. If the row index list contains a list of indicies for a given attribute, then executemany markers are used.

Parameters:
  • rowIndexList (list(tuple(str, object))) - List of specific rows to update, in the form (attrName, PyValue), e.g. [("multiframeId", 101)].
Returns: str
A SQL WHERE clause.

_executeScript(self, script, parameters=None, wantResult=False, wantAll=True, wantRowCount=False)

source code 

Send any SQL script to the server to execute. Specific DBMS errors that are just warnings are trapped to prevent processing from halting.

Parameters:
  • script (str) - The script which is to be processed.
  • parameters (list(tuple)) - Optionally supply parameter set if script contains executemany wildcards.
  • wantResult (bool) - If True, return results.
  • wantAll (bool) - If wantResult is True and wantAll is True then return all results otherwise just first result.
  • wantRowCount - If True, and results aren't returned then a count of affected rows are returned instead.
  • wantRowCount - bool
Returns: list(tuple) or int
The result of the executed script (if wantResult), or number of rows affected (if wantRowCount).

_getCursor(self)

source code 

Method to obtain cursor for current DbSession. If database connection is currently offline then an endless reconnect attempt is made.

Returns: Cursor
The cursor for the current DbSession.

_splitTablePath(self, tablePath)

source code 

Decomposes a full table path to its individual components.

Parameters:
  • tablePath (str) - Path to a table in the format "table" or "database.table" or "server.database..table" or "server.database.dbo.table"
Returns: tuple(str, str, str)
Server name, database name, table name from given path.

_sqlString(self, value)

source code 
Returns: str
An SQL string of the correct format for the data type.

Class Variable Details [hide private]

_dbConnections

Session manager. Stores one session per database.

Value:
{}