Cursor¶
-
class
ctds.
Cursor
¶ A database cursor used to manage the context of a fetch operation.
-
Parameter
¶ Convenience method to
ctds.Parameter
.- Returns
A new Parameter object.
- Return type
-
__enter__
()¶ Enter the cursor’s runtime context. On exit, the cursor is closed automatically.
- Returns
The cursor object.
- Return type
-
__exit__
(exc_type, exc_val, exc_tb)¶ Exit the cursor’s runtime context, closing the cursor.
- Parameters
- Returns
-
__iter__
()¶ Implement iter(self).
-
__next__
()¶ Implement next(self).
-
arraysize
¶ The number of rows to fetch at a time with
fetchmany()
.- Return type
-
callproc
(sproc, parameters)¶ Call a stored database procedure with the given name. The sequence of parameters must contain one entry for each argument that the procedure expects. The result of the call is returned as modified copy of the input sequence. Input parameters are left untouched. Output and input/output parameters are replaced with output values.
Warning
Due to FreeTDS implementation details, stored procedures with both output parameters and resultsets are not supported.
Warning
Currently FreeTDS does not support passing empty string parameters. Empty strings are converted to NULL values internally before being transmitted to the database.
- Parameters
- Returns
The input parameters with any output parameters replaced with the output values.
- Return type
-
close
()¶ Close the cursor.
-
connection
¶ A reference to the Connection object on which the cursor was created.
- Return type
-
description
¶ A description of the current result set columns. The description is a sequence of tuples, one tuple per column in the result set. The tuple describes the column data as follows:
name
The name of the column, if provided.
type_code
The specific type of the column.
display_size
The SQL type size of the column.
internal_size
The client size of the column.
precision
The precision of NUMERIC and DECIMAL columns.
scale
The scale of NUMERIC and DECIMAL columns.
null_ok
Whether the column allows NULL.
Note
In Python 3+, this is a
tuple
ofcollections.namedtuple()
objects whose members are defined above.
-
execute
(sql, parameters=None)¶ Prepare and execute a database operation. Parameters may be provided as sequence and will be bound to variables specified in the SQL statement. Parameter notation is specified by
ctds.paramstyle
.
-
executemany
(sql, seq_of_parameters)¶ Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.
-
fetchall
()¶ Fetch all (remaining) rows of a query result, returning them as a sequence of sequences.
- Returns
A sequence of result rows.
- Return type
-
fetchmany
(size=self.arraysize)¶ Fetch the next set of rows of a query result, returning a sequence of sequences. An empty sequence is returned when no more rows are available.
- Returns
A sequence of result rows.
- Return type
-
fetchone
()¶ Fetch the next row of a query result set, returning a single sequence, or
None
when no more data is available.- Returns
The next row or
None
.
-
next
()¶ Return the next row from the currently executing SQL statement using the same semantics as
fetchone()
. AStopIteration
exception is raised when the result set is exhausted.- Raises
StopIteration – The result set is exhausted.
- Returns
The next row.
-
nextset
()¶ Skip to the next available set, discarding any remaining rows from the current set.
-
rowcount
¶ The number of rows that the last
execute()
produced or affected.Note
This value is unreliable when
execute()
is called with parameters and using a version of FreeTDS prior to 1.1.- Return type
-
rownumber
¶ The current 0-based index of the cursor in the result set or
None
if the index cannot be determined.- Return type
-
setinputsizes
()¶ This method has no effect.
-
setoutputsize
()¶ This method has no effect.
-