| |
- __builtin__.object
-
- STdatabase
-
- STMockDB
- STPooledConnectionDB
-
- STMSSQL
- STODBC
- STSybase
- mockdb
- mockdb_connection
- mockdb_cursor
- stpydbConnection
-
- MSSQLConnection
- MockConnection
- ODBCConnection
- SybaseConnection
- stpydbCursor
-
- stpydbMSSQLCursor
- stpydbODBCCursor
- stpydbSybaseCursor
- stpydbmockCursor
- exceptions.Exception(exceptions.BaseException)
-
- mockdbError
- stpydbErrorHandler
class STMSSQL(STPooledConnectionDB) |
| |
- Method resolution order:
- STMSSQL
- STPooledConnectionDB
- STdatabase
- __builtin__.object
Methods defined here:
- __init__(self, serverName, dbmsName, moduleName='')
- Constructor used to establish connection to the database.
It contains the necessary parameters needed to make a connection
as outlined in the formal parameter list above.
Note the following example constructor calls: '
import stpydb
q1 = stpydb.stpydb()
q2 = stpydb.stpydb('R2D2', 'pstdev1')
q3 = stpydb.stpydb('R2D2', 'pstdev1', 'xyz.py')
q4 = stpydb.stpydb(dbmsName='pstdev1')
- beginTransaction(self, name=None)
- pymssql doesn't really support transactions, but turning autocommit off means that
you must do a 'commit' for the transaction to stick.
- callproc(self, name, params=(), return_status=False)
- Execute a stored procedure. Paramaters to the procedure can
be a sequence or dictionary which contains one entry for each
argument that the procedure expects. Examples:
c.callproc('sp_who')
c.callproc('sp_columns', ['pm_constants'])
c.callproc('sp_columns', {'table_name': 'pm_constants', 'column_name': 'number_of_gyros'})
A list of dictionaries is returned.
- query(self, queryString)
- Builds up a query string for eventual execution.
It continually concatenates the string passed into an internal buffer
and ships it to the database when one of the execute methods is called.
Replaces all double-quotes with single quotes since these are not equal
to MS SQL Server.
Methods inherited from STdatabase:
- begin(self, name=None)
- See beginTransaction.
- clear(self)
- Clears the current stpydb object for use in another query.
This must be done if you exit out of an execute() loop prior to
fetching all of the data.
- close(self)
- Closes down a connection for the particular server and database combination.
Notes:
1 No more queries can be executed on the object. Attempting this
will result in an error.
2 This is normally not called by the average Python utility!
This is because the connection is automatically closed for you when
the application terminates. You should only use this when you
have a long running application, such as a GUI, where you do not
want to hold open idle database resources for a long time.
- commit(self, name=None)
- See commitTransaction.
- commitTransaction(self, name=None)
- Commits the previous transaction.
Commits a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server).
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and rollbackTransaction()
- execute(self, results, updateMode=False)
- Executes a query. One row is return through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). This is executed within a loop and the loop
will fire for each row that gets returned or processed.
This method takes a parameter that can be either a Python list
or a Python dictionary. The query results are returned one row at
a time in 'results'.
* When the result is passed back as a list, you must get at the result
data by indexing into the list. This list is in column order of the
query. The column ordering starts at 0. Note that this can get
complicated for wildcard select statements or for large queries.
* When the result is passed back as a dictionary, you can obtain the
column value by using the column name (exact name with correct case)
as the index to the dictionary.
Note that query column names are determined defacto when possible.
However, if you use an SQL feature such as an aggregate, you must
provide a column name for the dictionary interface to behave properly.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: executeAll() and executeUpdate()
- executeAll(self, results)
- Executes a query and returns all rows at once through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). The entire query is exectued and returned
instead of returning one single row as in execute().
This method takes a parameter that can be either a list of Python lists
or a list of Python dictionaries. Again all query results are
returned. See execute() for details on the list and dictionary that
is returned to determine what method you want to use.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeUpdate()
- executeUpdate(self)
- Executes an update, insert, or other SQL DML query on the connection.
This should be used for executing any query that will change the
contents or settings in the database.
Remember that the udpate query has been built up in the prior
query() calls.
Useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeAll()
- getDescription(self)
- Get the description information.
Returns a meta data information about the most recently executed
select query. This format of the data is lightly described in
the API - see that for further details. At a high level it
contains column specific information including its name, data type,
size, and some other information.
Notes:
* If you run this function before a query has been processed through
execute() or executeAll() the return value will be None.
* You can call the method printDescription() to get a feel for the
each element in the dictionary type of information that is returned.
* The order of data in each tuple of the list is:
1 field name
2 field type code
3 field display size
4 field internal size
5 field precision
6 field scale
7 field nulls OK status
See also: printDescription()
- getParamModeChar(self)
- Returns the parameter substitution character currently in use.
See also: setParamModeChar()
- getRowcount(self)
- Returns the rowcount of the previously executed query.
You should not call this until after the query has completed execution.
- printDescription(self)
- Prints the descriptions of the query columns in the previously executed select statement.
See also: getDescription()
- printQuery(self)
- # Private member that displays the query through the debug interface
- rollback(self, name=None)
- See rollbackTransaction.
- rollbackTransaction(self, name=None)
- Execute a transaction rollback.
Rolls back a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server). A rollback means any
updates applied during the transaction are erased and the database
is rolled back to the state prior to the start of the transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and commitTransaction()
- setParam(self, paramName, value=None)
- Set a parameter within a query.
This is used to set the values for parameters in a query. It
provides a generic parameter passing mechanism for your queries.
This was originally done because the API query mechanisms did not
work.
Restrictions:
* Currently only parameter types String, Int, Long, and Float are
supported.
* Strings with nested single quoted may not work.
paramName format Notes:
* If paramName is a string, it is assumed to be the parameter
name and 'value' its value.
* if paramName is a list with the first element a string, the
first element is assumed to be the parameter name and the
second the value. The parameter 'value' is ignored.
* If paramName is a list of lists, each sublist is a parameter
name and value pair. The parameter 'value' is ignored.
- setParamModeChar(self, modeChar)
- Allows you to override the default parameter substitution character.
See also: getParamModeChar()
Data descriptors inherited from STdatabase:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from STdatabase:
- myConnId = 0
- queryInProgress = False
|
class STMockDB(STdatabase) |
| |
- Method resolution order:
- STMockDB
- STdatabase
- __builtin__.object
Methods defined here:
- __init__(self, serverName, dbmsName, moduleName='')
- Constructor used to establish a connection to a mock database.
The mock database can be pre-loaded with the return results.
Useful for testing, where a connection to a real database could prove problematic
because the returned results from a real database may vary over time.
- set_result(self, result)
Methods inherited from STdatabase:
- begin(self, name=None)
- See beginTransaction.
- beginTransaction(self, name=None)
- Activates a transaction on the current connection.
The transaction must eventually be committed or rolled back via the
commitTransaction() or rollbackTransaction() calls. Failure to do this
prior to the connection close (explicit or at image exit) will result
in a rollback transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
Notes:
* Not all databases support transactions - use this accordingly.
* Nested transactions are supported IFF the database supports them.
* Named trasactions are not currently supported in this interface.
See also: commitTransaction() and rollbackTransaction()
- callproc(self, name, params=())
- Execute a stored procedure. Paramaters to the procedure can
be a sequence or dictionary which contains one entry for each
argument that the procedure expects. Examples:
c.callproc('sp_who')
c.callproc('sp_columns', ['pm_constants'])
c.callproc('sp_columns', {'table_name': 'pm_constants', 'column_name': 'number_of_gyros'})
A list of dictionaries is returned.
- clear(self)
- Clears the current stpydb object for use in another query.
This must be done if you exit out of an execute() loop prior to
fetching all of the data.
- close(self)
- Closes down a connection for the particular server and database combination.
Notes:
1 No more queries can be executed on the object. Attempting this
will result in an error.
2 This is normally not called by the average Python utility!
This is because the connection is automatically closed for you when
the application terminates. You should only use this when you
have a long running application, such as a GUI, where you do not
want to hold open idle database resources for a long time.
- commit(self, name=None)
- See commitTransaction.
- commitTransaction(self, name=None)
- Commits the previous transaction.
Commits a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server).
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and rollbackTransaction()
- execute(self, results, updateMode=False)
- Executes a query. One row is return through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). This is executed within a loop and the loop
will fire for each row that gets returned or processed.
This method takes a parameter that can be either a Python list
or a Python dictionary. The query results are returned one row at
a time in 'results'.
* When the result is passed back as a list, you must get at the result
data by indexing into the list. This list is in column order of the
query. The column ordering starts at 0. Note that this can get
complicated for wildcard select statements or for large queries.
* When the result is passed back as a dictionary, you can obtain the
column value by using the column name (exact name with correct case)
as the index to the dictionary.
Note that query column names are determined defacto when possible.
However, if you use an SQL feature such as an aggregate, you must
provide a column name for the dictionary interface to behave properly.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: executeAll() and executeUpdate()
- executeAll(self, results)
- Executes a query and returns all rows at once through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). The entire query is exectued and returned
instead of returning one single row as in execute().
This method takes a parameter that can be either a list of Python lists
or a list of Python dictionaries. Again all query results are
returned. See execute() for details on the list and dictionary that
is returned to determine what method you want to use.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeUpdate()
- executeUpdate(self)
- Executes an update, insert, or other SQL DML query on the connection.
This should be used for executing any query that will change the
contents or settings in the database.
Remember that the udpate query has been built up in the prior
query() calls.
Useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeAll()
- getDescription(self)
- Get the description information.
Returns a meta data information about the most recently executed
select query. This format of the data is lightly described in
the API - see that for further details. At a high level it
contains column specific information including its name, data type,
size, and some other information.
Notes:
* If you run this function before a query has been processed through
execute() or executeAll() the return value will be None.
* You can call the method printDescription() to get a feel for the
each element in the dictionary type of information that is returned.
* The order of data in each tuple of the list is:
1 field name
2 field type code
3 field display size
4 field internal size
5 field precision
6 field scale
7 field nulls OK status
See also: printDescription()
- getParamModeChar(self)
- Returns the parameter substitution character currently in use.
See also: setParamModeChar()
- getRowcount(self)
- Returns the rowcount of the previously executed query.
You should not call this until after the query has completed execution.
- printDescription(self)
- Prints the descriptions of the query columns in the previously executed select statement.
See also: getDescription()
- printQuery(self)
- # Private member that displays the query through the debug interface
- query(self, queryString)
- Builds up a query string for eventual execution.
It continually concatenates the string passed into an internal buffer
and ships it to the database when one of the execute methods is called.
- rollback(self, name=None)
- See rollbackTransaction.
- rollbackTransaction(self, name=None)
- Execute a transaction rollback.
Rolls back a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server). A rollback means any
updates applied during the transaction are erased and the database
is rolled back to the state prior to the start of the transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and commitTransaction()
- setParam(self, paramName, value=None)
- Set a parameter within a query.
This is used to set the values for parameters in a query. It
provides a generic parameter passing mechanism for your queries.
This was originally done because the API query mechanisms did not
work.
Restrictions:
* Currently only parameter types String, Int, Long, and Float are
supported.
* Strings with nested single quoted may not work.
paramName format Notes:
* If paramName is a string, it is assumed to be the parameter
name and 'value' its value.
* if paramName is a list with the first element a string, the
first element is assumed to be the parameter name and the
second the value. The parameter 'value' is ignored.
* If paramName is a list of lists, each sublist is a parameter
name and value pair. The parameter 'value' is ignored.
- setParamModeChar(self, modeChar)
- Allows you to override the default parameter substitution character.
See also: getParamModeChar()
Data descriptors inherited from STdatabase:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from STdatabase:
- myConnId = 0
- queryInProgress = False
|
class STODBC(STPooledConnectionDB) |
| |
- Method resolution order:
- STODBC
- STPooledConnectionDB
- STdatabase
- __builtin__.object
Methods defined here:
- __init__(self, serverName, dbmsName, moduleName='')
- beginTransaction(self, name=None)
- PyODBC doesn't really support transactions, but turning autocommit off means that
you must do a 'commit' for the transaction to stick.
- callproc(self, name, params=(), return_status=False)
- Execute a stored procedure. Paramaters to the procedure can
be a sequence or dictionary which contains one entry for each
argument that the procedure expects. Examples:
c.callproc('sp_who')
c.callproc('sp_columns', ['pm_constants'])
c.callproc('sp_columns', {'table_name': 'pm_constants', 'column_name': 'number_of_gyros'})
A list of dictionaries is returned.
- commitTransaction(self, name=None)
- Commit the transaction and turn autocommit back ON, since beginTransaction turned it OFF
- query(self, queryString)
- Builds up a query string for eventual execution.
It continually concatenates the string passed into an internal buffer
and ships it to the database when one of the execute methods is called.
Replaces all double-quotes with single quotes since these are not equal
to MS SQL Server.
Methods inherited from STdatabase:
- begin(self, name=None)
- See beginTransaction.
- clear(self)
- Clears the current stpydb object for use in another query.
This must be done if you exit out of an execute() loop prior to
fetching all of the data.
- close(self)
- Closes down a connection for the particular server and database combination.
Notes:
1 No more queries can be executed on the object. Attempting this
will result in an error.
2 This is normally not called by the average Python utility!
This is because the connection is automatically closed for you when
the application terminates. You should only use this when you
have a long running application, such as a GUI, where you do not
want to hold open idle database resources for a long time.
- commit(self, name=None)
- See commitTransaction.
- execute(self, results, updateMode=False)
- Executes a query. One row is return through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). This is executed within a loop and the loop
will fire for each row that gets returned or processed.
This method takes a parameter that can be either a Python list
or a Python dictionary. The query results are returned one row at
a time in 'results'.
* When the result is passed back as a list, you must get at the result
data by indexing into the list. This list is in column order of the
query. The column ordering starts at 0. Note that this can get
complicated for wildcard select statements or for large queries.
* When the result is passed back as a dictionary, you can obtain the
column value by using the column name (exact name with correct case)
as the index to the dictionary.
Note that query column names are determined defacto when possible.
However, if you use an SQL feature such as an aggregate, you must
provide a column name for the dictionary interface to behave properly.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: executeAll() and executeUpdate()
- executeAll(self, results)
- Executes a query and returns all rows at once through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). The entire query is exectued and returned
instead of returning one single row as in execute().
This method takes a parameter that can be either a list of Python lists
or a list of Python dictionaries. Again all query results are
returned. See execute() for details on the list and dictionary that
is returned to determine what method you want to use.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeUpdate()
- executeUpdate(self)
- Executes an update, insert, or other SQL DML query on the connection.
This should be used for executing any query that will change the
contents or settings in the database.
Remember that the udpate query has been built up in the prior
query() calls.
Useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeAll()
- getDescription(self)
- Get the description information.
Returns a meta data information about the most recently executed
select query. This format of the data is lightly described in
the API - see that for further details. At a high level it
contains column specific information including its name, data type,
size, and some other information.
Notes:
* If you run this function before a query has been processed through
execute() or executeAll() the return value will be None.
* You can call the method printDescription() to get a feel for the
each element in the dictionary type of information that is returned.
* The order of data in each tuple of the list is:
1 field name
2 field type code
3 field display size
4 field internal size
5 field precision
6 field scale
7 field nulls OK status
See also: printDescription()
- getParamModeChar(self)
- Returns the parameter substitution character currently in use.
See also: setParamModeChar()
- getRowcount(self)
- Returns the rowcount of the previously executed query.
You should not call this until after the query has completed execution.
- printDescription(self)
- Prints the descriptions of the query columns in the previously executed select statement.
See also: getDescription()
- printQuery(self)
- # Private member that displays the query through the debug interface
- rollback(self, name=None)
- See rollbackTransaction.
- rollbackTransaction(self, name=None)
- Execute a transaction rollback.
Rolls back a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server). A rollback means any
updates applied during the transaction are erased and the database
is rolled back to the state prior to the start of the transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and commitTransaction()
- setParam(self, paramName, value=None)
- Set a parameter within a query.
This is used to set the values for parameters in a query. It
provides a generic parameter passing mechanism for your queries.
This was originally done because the API query mechanisms did not
work.
Restrictions:
* Currently only parameter types String, Int, Long, and Float are
supported.
* Strings with nested single quoted may not work.
paramName format Notes:
* If paramName is a string, it is assumed to be the parameter
name and 'value' its value.
* if paramName is a list with the first element a string, the
first element is assumed to be the parameter name and the
second the value. The parameter 'value' is ignored.
* If paramName is a list of lists, each sublist is a parameter
name and value pair. The parameter 'value' is ignored.
- setParamModeChar(self, modeChar)
- Allows you to override the default parameter substitution character.
See also: getParamModeChar()
Data descriptors inherited from STdatabase:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from STdatabase:
- myConnId = 0
- queryInProgress = False
|
class STPooledConnectionDB(STdatabase) |
| |
- Method resolution order:
- STPooledConnectionDB
- STdatabase
- __builtin__.object
Methods inherited from STdatabase:
- __init__(self, serverName, dbmsName, moduleName='')
- Constructor used to establish connection to the database.
It contains the necessary parameters needed to make a connection
as outlined in the formal parameter list above.
Note the following example constructor calls: '
import stpydb
q1 = stpydb.stpydb()
q2 = stpydb.stpydb('R2D2', 'pstdev1')
q3 = stpydb.stpydb('R2D2', 'pstdev1', 'xyz.py')
q4 = stpydb.stpydb(dbmsName='pstdev1')
- begin(self, name=None)
- See beginTransaction.
- beginTransaction(self, name=None)
- Activates a transaction on the current connection.
The transaction must eventually be committed or rolled back via the
commitTransaction() or rollbackTransaction() calls. Failure to do this
prior to the connection close (explicit or at image exit) will result
in a rollback transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
Notes:
* Not all databases support transactions - use this accordingly.
* Nested transactions are supported IFF the database supports them.
* Named trasactions are not currently supported in this interface.
See also: commitTransaction() and rollbackTransaction()
- callproc(self, name, params=())
- Execute a stored procedure. Paramaters to the procedure can
be a sequence or dictionary which contains one entry for each
argument that the procedure expects. Examples:
c.callproc('sp_who')
c.callproc('sp_columns', ['pm_constants'])
c.callproc('sp_columns', {'table_name': 'pm_constants', 'column_name': 'number_of_gyros'})
A list of dictionaries is returned.
- clear(self)
- Clears the current stpydb object for use in another query.
This must be done if you exit out of an execute() loop prior to
fetching all of the data.
- close(self)
- Closes down a connection for the particular server and database combination.
Notes:
1 No more queries can be executed on the object. Attempting this
will result in an error.
2 This is normally not called by the average Python utility!
This is because the connection is automatically closed for you when
the application terminates. You should only use this when you
have a long running application, such as a GUI, where you do not
want to hold open idle database resources for a long time.
- commit(self, name=None)
- See commitTransaction.
- commitTransaction(self, name=None)
- Commits the previous transaction.
Commits a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server).
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and rollbackTransaction()
- execute(self, results, updateMode=False)
- Executes a query. One row is return through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). This is executed within a loop and the loop
will fire for each row that gets returned or processed.
This method takes a parameter that can be either a Python list
or a Python dictionary. The query results are returned one row at
a time in 'results'.
* When the result is passed back as a list, you must get at the result
data by indexing into the list. This list is in column order of the
query. The column ordering starts at 0. Note that this can get
complicated for wildcard select statements or for large queries.
* When the result is passed back as a dictionary, you can obtain the
column value by using the column name (exact name with correct case)
as the index to the dictionary.
Note that query column names are determined defacto when possible.
However, if you use an SQL feature such as an aggregate, you must
provide a column name for the dictionary interface to behave properly.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: executeAll() and executeUpdate()
- executeAll(self, results)
- Executes a query and returns all rows at once through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). The entire query is exectued and returned
instead of returning one single row as in execute().
This method takes a parameter that can be either a list of Python lists
or a list of Python dictionaries. Again all query results are
returned. See execute() for details on the list and dictionary that
is returned to determine what method you want to use.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeUpdate()
- executeUpdate(self)
- Executes an update, insert, or other SQL DML query on the connection.
This should be used for executing any query that will change the
contents or settings in the database.
Remember that the udpate query has been built up in the prior
query() calls.
Useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeAll()
- getDescription(self)
- Get the description information.
Returns a meta data information about the most recently executed
select query. This format of the data is lightly described in
the API - see that for further details. At a high level it
contains column specific information including its name, data type,
size, and some other information.
Notes:
* If you run this function before a query has been processed through
execute() or executeAll() the return value will be None.
* You can call the method printDescription() to get a feel for the
each element in the dictionary type of information that is returned.
* The order of data in each tuple of the list is:
1 field name
2 field type code
3 field display size
4 field internal size
5 field precision
6 field scale
7 field nulls OK status
See also: printDescription()
- getParamModeChar(self)
- Returns the parameter substitution character currently in use.
See also: setParamModeChar()
- getRowcount(self)
- Returns the rowcount of the previously executed query.
You should not call this until after the query has completed execution.
- printDescription(self)
- Prints the descriptions of the query columns in the previously executed select statement.
See also: getDescription()
- printQuery(self)
- # Private member that displays the query through the debug interface
- query(self, queryString)
- Builds up a query string for eventual execution.
It continually concatenates the string passed into an internal buffer
and ships it to the database when one of the execute methods is called.
- rollback(self, name=None)
- See rollbackTransaction.
- rollbackTransaction(self, name=None)
- Execute a transaction rollback.
Rolls back a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server). A rollback means any
updates applied during the transaction are erased and the database
is rolled back to the state prior to the start of the transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and commitTransaction()
- setParam(self, paramName, value=None)
- Set a parameter within a query.
This is used to set the values for parameters in a query. It
provides a generic parameter passing mechanism for your queries.
This was originally done because the API query mechanisms did not
work.
Restrictions:
* Currently only parameter types String, Int, Long, and Float are
supported.
* Strings with nested single quoted may not work.
paramName format Notes:
* If paramName is a string, it is assumed to be the parameter
name and 'value' its value.
* if paramName is a list with the first element a string, the
first element is assumed to be the parameter name and the
second the value. The parameter 'value' is ignored.
* If paramName is a list of lists, each sublist is a parameter
name and value pair. The parameter 'value' is ignored.
- setParamModeChar(self, modeChar)
- Allows you to override the default parameter substitution character.
See also: getParamModeChar()
Data descriptors inherited from STdatabase:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from STdatabase:
- myConnId = 0
- queryInProgress = False
|
class STSybase(STPooledConnectionDB) |
| |
- Method resolution order:
- STSybase
- STPooledConnectionDB
- STdatabase
- __builtin__.object
Methods defined here:
- __init__(self, serverName, dbmsName, moduleName='')
- Constructor used to establish connection to the database.
It contains the necessary parameters needed to make a connection
as outlined in the formal parameter list above.
Note the following example constructor calls: '
import stpydb
q1 = stpydb.stpydb()
q2 = stpydb.stpydb('R2D2', 'pstdev1')
q3 = stpydb.stpydb('R2D2', 'pstdev1', 'xyz.py')
q4 = stpydb.stpydb(dbmsName='pstdev1')
- beginTransaction(self, name=None)
- Activates a transaction on the current connection.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
- callproc(self, name, params=(), return_status=False)
- Execute a stored procedure. Paramaters to the procedure can
be a sequence or dictionary which contains one entry for each
argument that the procedure expects. Examples:
c.callproc('sp_who')
c.callproc('sp_columns', ['pm_constants'])
c.callproc('sp_columns', {'table_name': 'pm_constants', 'column_name': 'number_of_gyros'})
A list of dictionaries is returned.
- commitTransaction(self, name=None)
- Commits the previous transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
- rollbackTransaction(self, name=None)
- Execute a transaction rollback.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
Methods inherited from STdatabase:
- begin(self, name=None)
- See beginTransaction.
- clear(self)
- Clears the current stpydb object for use in another query.
This must be done if you exit out of an execute() loop prior to
fetching all of the data.
- close(self)
- Closes down a connection for the particular server and database combination.
Notes:
1 No more queries can be executed on the object. Attempting this
will result in an error.
2 This is normally not called by the average Python utility!
This is because the connection is automatically closed for you when
the application terminates. You should only use this when you
have a long running application, such as a GUI, where you do not
want to hold open idle database resources for a long time.
- commit(self, name=None)
- See commitTransaction.
- execute(self, results, updateMode=False)
- Executes a query. One row is return through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). This is executed within a loop and the loop
will fire for each row that gets returned or processed.
This method takes a parameter that can be either a Python list
or a Python dictionary. The query results are returned one row at
a time in 'results'.
* When the result is passed back as a list, you must get at the result
data by indexing into the list. This list is in column order of the
query. The column ordering starts at 0. Note that this can get
complicated for wildcard select statements or for large queries.
* When the result is passed back as a dictionary, you can obtain the
column value by using the column name (exact name with correct case)
as the index to the dictionary.
Note that query column names are determined defacto when possible.
However, if you use an SQL feature such as an aggregate, you must
provide a column name for the dictionary interface to behave properly.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: executeAll() and executeUpdate()
- executeAll(self, results)
- Executes a query and returns all rows at once through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). The entire query is exectued and returned
instead of returning one single row as in execute().
This method takes a parameter that can be either a list of Python lists
or a list of Python dictionaries. Again all query results are
returned. See execute() for details on the list and dictionary that
is returned to determine what method you want to use.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeUpdate()
- executeUpdate(self)
- Executes an update, insert, or other SQL DML query on the connection.
This should be used for executing any query that will change the
contents or settings in the database.
Remember that the udpate query has been built up in the prior
query() calls.
Useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeAll()
- getDescription(self)
- Get the description information.
Returns a meta data information about the most recently executed
select query. This format of the data is lightly described in
the API - see that for further details. At a high level it
contains column specific information including its name, data type,
size, and some other information.
Notes:
* If you run this function before a query has been processed through
execute() or executeAll() the return value will be None.
* You can call the method printDescription() to get a feel for the
each element in the dictionary type of information that is returned.
* The order of data in each tuple of the list is:
1 field name
2 field type code
3 field display size
4 field internal size
5 field precision
6 field scale
7 field nulls OK status
See also: printDescription()
- getParamModeChar(self)
- Returns the parameter substitution character currently in use.
See also: setParamModeChar()
- getRowcount(self)
- Returns the rowcount of the previously executed query.
You should not call this until after the query has completed execution.
- printDescription(self)
- Prints the descriptions of the query columns in the previously executed select statement.
See also: getDescription()
- printQuery(self)
- # Private member that displays the query through the debug interface
- query(self, queryString)
- Builds up a query string for eventual execution.
It continually concatenates the string passed into an internal buffer
and ships it to the database when one of the execute methods is called.
- rollback(self, name=None)
- See rollbackTransaction.
- setParam(self, paramName, value=None)
- Set a parameter within a query.
This is used to set the values for parameters in a query. It
provides a generic parameter passing mechanism for your queries.
This was originally done because the API query mechanisms did not
work.
Restrictions:
* Currently only parameter types String, Int, Long, and Float are
supported.
* Strings with nested single quoted may not work.
paramName format Notes:
* If paramName is a string, it is assumed to be the parameter
name and 'value' its value.
* if paramName is a list with the first element a string, the
first element is assumed to be the parameter name and the
second the value. The parameter 'value' is ignored.
* If paramName is a list of lists, each sublist is a parameter
name and value pair. The parameter 'value' is ignored.
- setParamModeChar(self, modeChar)
- Allows you to override the default parameter substitution character.
See also: getParamModeChar()
Data descriptors inherited from STdatabase:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from STdatabase:
- myConnId = 0
- queryInProgress = False
|
class STdatabase(__builtin__.object) |
| |
Methods defined here:
- __init__(self, serverName, dbmsName, moduleName='')
- Constructor used to establish connection to the database.
It contains the necessary parameters needed to make a connection
as outlined in the formal parameter list above.
Note the following example constructor calls: '
import stpydb
q1 = stpydb.stpydb()
q2 = stpydb.stpydb('R2D2', 'pstdev1')
q3 = stpydb.stpydb('R2D2', 'pstdev1', 'xyz.py')
q4 = stpydb.stpydb(dbmsName='pstdev1')
- begin(self, name=None)
- See beginTransaction.
- beginTransaction(self, name=None)
- Activates a transaction on the current connection.
The transaction must eventually be committed or rolled back via the
commitTransaction() or rollbackTransaction() calls. Failure to do this
prior to the connection close (explicit or at image exit) will result
in a rollback transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
Notes:
* Not all databases support transactions - use this accordingly.
* Nested transactions are supported IFF the database supports them.
* Named trasactions are not currently supported in this interface.
See also: commitTransaction() and rollbackTransaction()
- callproc(self, name, params=())
- Execute a stored procedure. Paramaters to the procedure can
be a sequence or dictionary which contains one entry for each
argument that the procedure expects. Examples:
c.callproc('sp_who')
c.callproc('sp_columns', ['pm_constants'])
c.callproc('sp_columns', {'table_name': 'pm_constants', 'column_name': 'number_of_gyros'})
A list of dictionaries is returned.
- clear(self)
- Clears the current stpydb object for use in another query.
This must be done if you exit out of an execute() loop prior to
fetching all of the data.
- close(self)
- Closes down a connection for the particular server and database combination.
Notes:
1 No more queries can be executed on the object. Attempting this
will result in an error.
2 This is normally not called by the average Python utility!
This is because the connection is automatically closed for you when
the application terminates. You should only use this when you
have a long running application, such as a GUI, where you do not
want to hold open idle database resources for a long time.
- commit(self, name=None)
- See commitTransaction.
- commitTransaction(self, name=None)
- Commits the previous transaction.
Commits a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server).
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and rollbackTransaction()
- execute(self, results, updateMode=False)
- Executes a query. One row is return through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). This is executed within a loop and the loop
will fire for each row that gets returned or processed.
This method takes a parameter that can be either a Python list
or a Python dictionary. The query results are returned one row at
a time in 'results'.
* When the result is passed back as a list, you must get at the result
data by indexing into the list. This list is in column order of the
query. The column ordering starts at 0. Note that this can get
complicated for wildcard select statements or for large queries.
* When the result is passed back as a dictionary, you can obtain the
column value by using the column name (exact name with correct case)
as the index to the dictionary.
Note that query column names are determined defacto when possible.
However, if you use an SQL feature such as an aggregate, you must
provide a column name for the dictionary interface to behave properly.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: executeAll() and executeUpdate()
- executeAll(self, results)
- Executes a query and returns all rows at once through 'results'.
Executes a select query (remember that the query has been built up
in the query() calls). The entire query is exectued and returned
instead of returning one single row as in execute().
This method takes a parameter that can be either a list of Python lists
or a list of Python dictionaries. Again all query results are
returned. See execute() for details on the list and dictionary that
is returned to determine what method you want to use.
Finally, useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeUpdate()
- executeUpdate(self)
- Executes an update, insert, or other SQL DML query on the connection.
This should be used for executing any query that will change the
contents or settings in the database.
Remember that the udpate query has been built up in the prior
query() calls.
Useful run-time debug information can be obtained when the
appropriate settings have been made prior to execution by the user.
See also: execute() and executeAll()
- getDescription(self)
- Get the description information.
Returns a meta data information about the most recently executed
select query. This format of the data is lightly described in
the API - see that for further details. At a high level it
contains column specific information including its name, data type,
size, and some other information.
Notes:
* If you run this function before a query has been processed through
execute() or executeAll() the return value will be None.
* You can call the method printDescription() to get a feel for the
each element in the dictionary type of information that is returned.
* The order of data in each tuple of the list is:
1 field name
2 field type code
3 field display size
4 field internal size
5 field precision
6 field scale
7 field nulls OK status
See also: printDescription()
- getParamModeChar(self)
- Returns the parameter substitution character currently in use.
See also: setParamModeChar()
- getRowcount(self)
- Returns the rowcount of the previously executed query.
You should not call this until after the query has completed execution.
- printDescription(self)
- Prints the descriptions of the query columns in the previously executed select statement.
See also: getDescription()
- printQuery(self)
- # Private member that displays the query through the debug interface
- query(self, queryString)
- Builds up a query string for eventual execution.
It continually concatenates the string passed into an internal buffer
and ships it to the database when one of the execute methods is called.
- rollback(self, name=None)
- See rollbackTransaction.
- rollbackTransaction(self, name=None)
- Execute a transaction rollback.
Rolls back a previously activated transaction on the current connection.
If there is no transaction active the call may result in an
error (depending on the database server). A rollback means any
updates applied during the transaction are erased and the database
is rolled back to the state prior to the start of the transaction.
The optional name argument allows you to make use of the Sybase ability
to nest and name transactions.
See also: beginTransaction() and commitTransaction()
- setParam(self, paramName, value=None)
- Set a parameter within a query.
This is used to set the values for parameters in a query. It
provides a generic parameter passing mechanism for your queries.
This was originally done because the API query mechanisms did not
work.
Restrictions:
* Currently only parameter types String, Int, Long, and Float are
supported.
* Strings with nested single quoted may not work.
paramName format Notes:
* If paramName is a string, it is assumed to be the parameter
name and 'value' its value.
* if paramName is a list with the first element a string, the
first element is assumed to be the parameter name and the
second the value. The parameter 'value' is ignored.
* If paramName is a list of lists, each sublist is a parameter
name and value pair. The parameter 'value' is ignored.
- setParamModeChar(self, modeChar)
- Allows you to override the default parameter substitution character.
See also: getParamModeChar()
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- myConnId = 0
- queryInProgress = False
|
class mockdb(__builtin__.object) |
| |
Methods defined here:
- __init__(self)
- connect(self)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
|