Once you have connected to the database you will need a Cursor
object with which to manipulate the database. Cursor stands for a "CURrent Set Of Results".
import web, web.database connection = web.database.connect(type="mysql", database="test") cursor = connection.cursor()
Once we have the connection to the database, connection
, we can easily create a cursor by calling the connection
's cursor() method.
Note: The cursor produced passes any calls to unknown attributes or function directly to the underlying DB-API 2.0 cursor. This means the cursor produced in the code above will behave exaclty like the cursor on which it is based but will also have additional methods.
The cursor() method takes the following options and will return the appropriate cursor object:
[autoExecute,][convertMode,][colTypesName,][types]) |
False
the SQL generated by methods like select() or create() is never executed but instead the SQL is returned as a String. If set to True
the functions will execute the SQL and then return the SQL, or in the case of the select() method, will return the result of calling fetchRows(). The default is True
.
'table'
to store the data in a table whose name is specified by the colTypesName
option. Can be 'description'
to retrieve the type information from the cursor.description
object. Not all databases support both options.
'ColTypes'
.
_typesCache
. Each table should have a dictionary where the field names are the keys and the field code integers are the values. The types
dictionary should be a dictionary of these dictionaries where the keys are the table names.
self.debug
? Can be either True
or False
. Default is False
.
See About this document... for information on suggesting changes.