Implements the DB-API 2.0 Cursor class.
Cursor objects have the following interface:
A list of 7-item tuples. Each of the tuples describes one result
column: (name, type_code, display_size, internal_size,
precision, scale, null_ok)
. This attribute will be None
for
operations which do not return rows or if the cursor has not had an
operation invoked via execute() or executemany().
The type_code
can be interpreted by comparing it to the
DBAPITypeObject objects STRING
, BINARY
,
NUMBER
, DATETIME
, or ROWID
.
This attribute reports the number of rows that the last execute() or executemany() method produced or affected.
The attribute is -1
if no execute() or
executemany() has been performed on the cursor.
procname [, parameters]) |
Calls the stored database procedure named in the procname argument. The optional parameters argument can be a sequence or dictionary which contains one entry for each argument that the procedure expects. For example:
c.callproc('sp_help', ['titles']) c.callproc('sp_help', {'@objname': 'titles'})
The DB-API 2.0 specification says:
The result of the call is returned as modified copy of the input sequence. Input parameters are left untouched, output and input/output parameters replaced with possibly new values.
This method is is not DB-API compliant in because there does not seem
to be a way to query Sybase to determine which parameters are output
parameters. This method returns None
.
The procedure may also provide a result set as output. This can be retrieved via the fetchone(), fetchmany(), and fetchall() methods.
) |
Cancels any pending results immediately. Any operation on the cursor after calling this method will raise an exception.
This method is called by the __del__() method.
sql [, params]) |
Prepares a dynamic SQL command on the Sybase server and executes it. The optional params argument is a dictionary of parameters which are bound as parameters to the dynamic SQL command. Sybase uses name place holders to specify which the parameters will be used by the SQL command.
import Sybase db = Sybase.connect('SYBASE', 'sa', '', 'pubs2') c = db.cursor() c.execute("select * from titles where price > @price", {'@price': 15.00}) c.fetchall()
The prepared dynamic SQL will be reused by the cursor if the same SQL is passed in the sql argument. This is most effective for algorithms where the same operation is used, but different parameters are bound to it (many times).
The method returns None
.
sql, params_seq) |
Calls the execute() method for every parameter sequence in the sequence passed as the params_seq argument.
The method returns None
.
) |
Fetches the next row of a logical result and returns it as a tuple.
None
is returned when no more rows are available in the logical
result.
[size = cursor.arraysize ]) |
Fetches the next set of rows of a logical result, returning a list of tuples. An empty list is returned when no more rows are available.
The number of rows to fetch per call is specified by the optional size argument. If size is not supplied, the arraysize member determines the number of rows to be fetched. The method will try to fetch the number of rows indicated by the size parameter. If this is not possible due to the specified number of rows not being available, fewer rows will be returned.
) |
Fetches all remaining rows of a logical result returning them as a list of tuples.
) |
Makes the cursor skip to the next logical result, discarding any remaining rows from the current logical result.
If there are no more logical results, the method returns None
.
Otherwise, it returns 1
and subsequent calls to the
fetchone(), fetchmany(), and fetchall()
methods will return rows from the next logical result.
This read/write attribute specifies the number of rows to fetch at a
time with fetchmany(). It defaults to 1
meaning to
fetch a single row at a time.
size) |
This method does nothing - it is provided for DB-API compliance.
size [, column]) |
This method does nothing - it is provided for DB-API compliance.