Package MySQLdb :: Module cursors :: Class BaseCursor
[hide private]
[frames] | no frames]

Class BaseCursor

source code

object --+
         |
        BaseCursor
Known Subclasses:
Cursor, DictCursor, SSCursor, SSDictCursor

A base for Cursor classes. Useful attributes:

description
    A tuple of DB API 7-tuples describing the columns in
    the last executed query; see PEP-249 for details.

description_flags
    Tuple of column flags for last query, one entry per column
    in the result set. Values correspond to those in
    MySQLdb.constants.FLAG. See MySQL documentation (C API)
    for more information. Non-standard extension.

arraysize
    default number of rows fetchmany() will fetch



Nested Classes [hide private]
  Warning
Exception raised for important warnings like data truncations while inserting, etc.
  Error
Exception that is the base class of all other error exceptions (not Warning).
  InterfaceError
Exception raised for errors that are related to the database interface rather than the database itself.
  DatabaseError
Exception raised for errors that are related to the database.
  DataError
Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc.
  OperationalError
Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer, e.g.
  IntegrityError
Exception raised when the relational integrity of the database is affected, e.g.
  InternalError
Exception raised when the database encounters an internal error, e.g.
  ProgrammingError
Exception raised for programming errors, e.g.
  NotSupportedError
Exception raised in case a method or database API was used which is not supported by the database, e.g.
Instance Methods [hide private]
 
__init__(self, connection)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__del__(self) source code
 
close(self)
Close the cursor.
source code
 
_check_executed(self) source code
 
_warning_check(self) source code
 
nextset(self)
Advance to the next result set.
source code
 
_post_get_result(self) source code
 
_do_get_result(self) source code
 
setinputsizes(self, *args)
Does nothing, required by DB API.
source code
 
setoutputsizes(self, *args)
Does nothing, required by DB API.
source code
 
_get_db(self) source code
 
execute(self, query, args=None)
Execute a query.
source code
 
executemany(self, query, args)
Execute a multi-row query.
source code
 
callproc(self, procname, args=())
Execute stored procedure procname with args
source code
 
_do_query(self, q) source code
 
_query(self, q) source code
 
_fetch_row(self, size=1) source code
 
__iter__(self) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  _defer_warnings = False
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, connection)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

close(self)

source code 
Close the cursor. No further queries will be possible.

nextset(self)

source code 

Advance to the next result set.

Returns None if there are no more result sets.

execute(self, query, args=None)

source code 

Execute a query.

query -- string, query to execute on server args -- optional sequence or mapping, parameters to use with query.

Note: If args is a sequence, then %s must be used as the parameter placeholder in the query. If a mapping is used, %(key)s must be used as the placeholder.

Returns long integer rows affected, if any

executemany(self, query, args)

source code 
Execute a multi-row query.

query -- string, query to execute on server

args

    Sequence of sequences or mappings, parameters to use with
    query.
    
Returns long integer rows affected, if any.

This method improves performance on multiple-row INSERT and
REPLACE. Otherwise it is equivalent to looping over args with
execute().

callproc(self, procname, args=())

source code 

Execute stored procedure procname with args

procname -- string, name of procedure to execute on server

args -- Sequence of parameters to use with procedure

Returns the original args.

Compatibility warning: PEP-249 specifies that any modified parameters must be returned. This is currently impossible as they are only available by storing them in a server variable and then retrieved by a query. Since stored procedures return zero or more result sets, there is no reliable way to get at OUT or INOUT parameters via callproc. The server variables are named @_procname_n, where procname is the parameter above and n is the position of the parameter (from zero). Once all result sets generated by the procedure have been fetched, you can issue a SELECT @_procname_0, ... query using .execute() to get any OUT or INOUT values.

Compatibility warning: The act of calling a stored procedure itself creates an empty result set. This appears after any result sets generated by the procedure. This is non-standard behavior with respect to the DB-API. Be sure to use nextset() to advance through all result sets; otherwise you may get disconnected.