An interface to our database. Manages the mxODBC connection, and
provides a set of wrappers to common SQL statements.
|
|
__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
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
dropTable(self,
tableSchema,
dbSchema)
Drops a table from the database, first removing any foreign key
constraints that reference the table. |
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
|
|
|
|
goOffline(self)
Temporarily drop the database connection, whilst keeping the
DbSession object alive. |
source code
|
|
|
|
|
|
int
|
|
|
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
|
|
|
scalar
|
queryAttrMax(self,
attrs,
table,
where='')
Wrapper to just query the maximum value of the given attributes. |
source code
|
|
|
list(str)
|
|
|
dict(str:str)
|
|
|
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
|
|
|
|
|
|
|
|
|
list(str)
|
|
|
|
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
|
|
|
|
|
|
int
|
|
|
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
|
|
|
|
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
|
|
|
|
_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)
|
|
|
str
|
|
|
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__repr__,
__setattr__,
__sizeof__,
__subclasshook__
|