rowcount
Returns number of rows affected by last operation. In case of
SELECT
statements it returns meaningful information only after all
rows have been fetched.
connection
This is the extension of the DB-API specification.
Returns a reference to the connection object on which the cursor was created.
lastrowid
This is the extension of the DB-API specification.
Returns identity value of last inserted row. If previous operation
did not involve inserting a row into a table with identity column,
None
is returned.
rownumber
This is the extension of the DB-API specification.
Returns current 0-based index of the cursor in the result set.
close
()
Close the cursor. The cursor is unusable from this point.
execute
(operation)
execute
(operation, params)
operation
is a string and
params
, if specified,
is a simple value, a tuple, or
None
.
Performs the operation against the database, possibly replacing parameter placeholders
with provided values. This should be preferred method
of creating SQL commands, instead of concatenating strings manually, what makes a
potential of
SQL Injection attacks.
This method accepts the same formatting as Python's builtin
string
interpolation operator.
If you call
execute()
with one argument, you can use % sign as usual in
your query string, for example in
LIKE
operator
(it loses its special meaning). See the example at the top.
executemany
(operation, params_seq)
operation
is a string and params_seq
is a sequence of tuples (e.g. a list). Execute a database operation repeatedly for each element
in parameter sequence.
fetchone
()
Fetch the next row of a query result, returning a tuple,
or a dictionary if as_dict
was passed to pymssql.connect()
, or
None
if no more data is available.
Raises OperationalError
if previous call to
execute*
()
did not produce any result set or no call was issued yet.
fetchmany
(size=None
)
Fetch the next batch of rows of a query result,
returning a list of tuples, or a list of dictionaries if as_dict
was passed to pymssql.connect()
,
or an empty list if no more data is available.
You can adjust the batch size using the size
parameter,
which is preserved across many calls to this method.
Raises OperationalError
if previous call to
execute*
()
did not produce any result set or no call was issued yet.
fetchall
()
Fetch all remaining rows of a query result, returning a list
of tuples, or a list of dictionaries if as_dict
was passed to pymssql.connect()
,
or an empty list if no more data is available.
Raises OperationalError
if previous call to
execute*
()
did not produce any result set or no call was issued yet.
fetchone_asdict
()
Warning: this method is not part of DB-API.
This method is deprecated as of pymsssql 1.0.2.
It was replaced by as_dict
parameter to pymssql.connect()
Fetch the next row of a query result, returning a dictionary, or
None
if no more data is available.
Data can be accessed by 0-based numeric column index, or by column name.
Raises OperationalError
if previous call to
execute*
()
did not produce any result set or no call was issued yet.
fetchmany_asdict
(size=None
)
Warning: this method is not part of DB-API.
This method is deprecated as of pymsssql 1.0.2.
It was replaced by as_dict
parameter to pymssql.connect()
Fetch the next batch of rows of a query result, returning a list of dictionaries.
An empty list is returned if no more data is available.
Data can be accessed by 0-based numeric column index, or by column name.
You can adjust the batch size using the size
parameter,
which is preserved across many calls to this method.
Raises OperationalError
if previous call to
execute*
()
did not produce any result set or no call was issued yet.
fetchall_asdict
()
Warning: this method is not part of DB-API.
This method is deprecated as of pymsssql 1.0.2.
It was replaced by as_dict
parameter to pymssql.connect()
Fetch all remaining rows of a query result, returning a list of dictionaries.
An empty list is returned if no more data is available.
Data can be accessed by 0-based numeric column index, or by column name.
Raises OperationalError
if previous call to
execute*
()
did not produce any result set or no call was issued yet.
The idea and original implementation of this method by Sterling Michel
<sterlingmichel_at_gmail_dot_com>
nextset
()
This method makes the cursor skip to the next
available result set, discarding any remaining rows from the current set.
Returns True value if next result is available, None if not.
__iter__
()
, next
()
These methods faciliate
Python iterator protocol.
You most likely will not call them directly, but indirectly by using iterators.
setinputsizes
()
, setoutputsize
()
These methods do nothing, as permitted by DB-API specs.