Docs for DAL.executesql

[ Python Tutorial ] [ Python Libraries ] [ web2py epydoc ]

Description


<type 'instancemethod'>

















































Executes an arbitrary query

Args:
query (str): the query to submit to the backend
placeholders: is optional and will always be None.
If using raw SQL with placeholders, placeholders may be
a sequence of values to be substituted in
or
, (if supported by the DB driver), a dictionary with keys
matching named placeholders in your SQL.
as_dict: will always be None when using DAL.
If using raw SQL can be set to True and the results cursor
returned by the DB driver will be converted to a sequence of
dictionaries keyed with the db field names. Results returned
with as_dict=True are the same as those returned when applying
.to_list() to a DAL query. If "as_ordered_dict"=True the
behaviour is the same as when "as_dict"=True with the keys
(field names) guaranteed to be in the same order as returned
by the select name executed on the database.
fields: list of DAL Fields that match the fields returned from the
DB. The Field objects should be part of one or more Table
objects defined on the DAL object. The "fields" list can include
one or more DAL Table objects in addition to or instead of
including Field objects, or it can be just a single table
(not in a list). In that case, the Field objects will be
extracted from the table(s).

Note:
if either `fields` or `colnames` is provided, the results
will be converted to a DAL `Rows` object using the
`db._adapter.parse()` method
colnames: list of field names in tablename.fieldname format

Note:
It is also possible to specify both "fields" and the associated
"colnames". In that case, "fields" can also include DAL Expression
objects in addition to Field objects. For Field objects in "fields",
the associated "colnames" must still be in tablename.fieldname
format. For Expression objects in "fields", the associated
"colnames" can be any arbitrary labels.

DAL Table objects referred to by "fields" or "colnames" can be dummy
tables and do not have to represent any real tables in the database.
Also, note that the "fields" and "colnames" must be in the
same order as the fields in the results cursor returned from the DB.



Attributes


DAL.executesql.__call__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__call__(...) <==> x(...)

DAL.executesql.__class__ <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
instancemethod(function, instance, class) Create an instance method object.

DAL.executesql.__cmp__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__cmp__(y) <==> cmp(x,y)

DAL.executesql.__delattr__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__delattr__('name') <==> del x.name

DAL.executesql.__doc__ <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

DAL.executesql.__format__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
default object formatter

DAL.executesql.__func__ <type 'function'> belongs to class <type 'function'>
Executes an arbitrary query Args: query (str): the query to submit to the backend placeholders: is optional and will always be None. If using raw SQL with placeholders, placeholders may be a sequence of values to be substituted in or, (if supported by the DB driver), a dictionary with keys matching named placeholders in your SQL. as_dict: will always be None when using DAL. If using raw SQL can be set to True and the results cursor returned by the DB driver will be converted to a sequence of dictionaries keyed with the db field names. Results returned with as_dict=True are the same as those returned when applying .to_list() to a DAL query. If "as_ordered_dict"=True the behaviour is the same as when "as_dict"=True with the keys (field names) guaranteed to be in the same order as returned by the select name executed on the database. fields: list of DAL Fields that match the fields returned from the DB. The Field objects should be part of one or more Table objects defined on the DAL object. The "fields" list can include one or more DAL Table objects in addition to or instead of including Field objects, or it can be just a single table (not in a list). In that case, the Field objects will be extracted from the table(s). Note: if either `fields` or `colnames` is provided, the results will be converted to a DAL `Rows` object using the `db._adapter.parse()` method colnames: list of field names in tablename.fieldname format Note: It is also possible to specify both "fields" and the associated "colnames". In that case, "fields" can also include DAL Expression objects in addition to Field objects. For Field objects in "fields", the associated "colnames" must still be in tablename.fieldname format. For Expression objects in "fields", the associated "colnames" can be any arbitrary labels. DAL Table objects referred to by "fields" or "colnames" can be dummy tables and do not have to represent any real tables in the database. Also, note that the "fields" and "colnames" must be in the same order as the fields in the results cursor returned from the DB.

DAL.executesql.__get__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
descr.__get__(obj[, type]) -> value

DAL.executesql.__getattribute__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__getattribute__('name') <==> x.name

DAL.executesql.__hash__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__hash__() <==> hash(x)

DAL.executesql.__init__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__init__(...) initializes x; see help(type(x)) for signature

DAL.executesql.__new__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
T.__new__(S, ...) -> a new object with type S, a subtype of T

DAL.executesql.__reduce__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
helper for pickle

DAL.executesql.__reduce_ex__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
helper for pickle

DAL.executesql.__repr__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__repr__() <==> repr(x)

DAL.executesql.__self__ <type 'NoneType'> belongs to class <type 'NoneType'>

DAL.executesql.__setattr__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__setattr__('name', value) <==> x.name = value

DAL.executesql.__sizeof__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
__sizeof__() -> int size of object in memory, in bytes

DAL.executesql.__str__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__str__() <==> str(x)

DAL.executesql.__subclasshook__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
Abstract classes can override this to customize issubclass(). This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

DAL.executesql.im_class <class 'pydal.base.MetaDAL'> extends (<class 'pydal.helpers.classes.Serializable'>, <class 'pydal.helpers.classes.BasicStorage'>) belongs to class <class 'pydal.base.MetaDAL'>
An instance of this class represents a database connection Args: uri(str): contains information for connecting to a database. Defaults to `'sqlite://dummy.db'` Note: experimental: you can specify a dictionary as uri parameter i.e. with:: db = DAL({"uri": "sqlite://storage.sqlite", "tables": {...}, ...}) for an example of dict input you can check the output of the scaffolding db model with db.as_dict() Note that for compatibility with Python older than version 2.6.5 you should cast your dict input keys to str due to a syntax limitation on kwarg names. for proper DAL dictionary input you can use one of:: obj = serializers.cast_keys(dict, [encoding="utf-8"]) #or else (for parsing json input) obj = serializers.loads_json(data, unicode_keys=False) pool_size: How many open connections to make to the database object. folder: where .table files will be created. Automatically set within web2py. Use an explicit path when using DAL outside web2py db_codec: string encoding of the database (default: 'UTF-8') table_hash: database identifier with .tables. If your connection hash change you can still using old .tables if they have db_hash as prefix check_reserved: list of adapters to check tablenames and column names against sql/nosql reserved keywords. Defaults to `None` - 'common' List of sql keywords that are common to all database types such as "SELECT, INSERT". (recommended) - 'all' Checks against all known SQL keywords - '<adaptername>'' Checks against the specific adapters list of keywords - '<adaptername>_nonreserved' Checks against the specific adapters list of nonreserved keywords. (if available) migrate: sets default migrate behavior for all tables fake_migrate: sets default fake_migrate behavior for all tables migrate_enabled: If set to False disables ALL migrations fake_migrate_all: If set to True fake migrates ALL tables attempts: Number of times to attempt connecting auto_import: If set to True, tries import automatically table definitions from the databases folder (works only for simple models) bigint_id: If set, turn on bigint instead of int for id and reference fields lazy_tables: delays table definition until table access after_connection: can a callable that will be executed after the connection Example: Use as:: db = DAL('sqlite://test.db') or:: db = DAL(**{"uri": ..., "tables": [...]...}) # experimental db.define_table('tablename', Field('fieldname1'), Field('fieldname2'))

DAL.executesql.im_func <type 'function'> belongs to class <type 'function'>
Executes an arbitrary query Args: query (str): the query to submit to the backend placeholders: is optional and will always be None. If using raw SQL with placeholders, placeholders may be a sequence of values to be substituted in or, (if supported by the DB driver), a dictionary with keys matching named placeholders in your SQL. as_dict: will always be None when using DAL. If using raw SQL can be set to True and the results cursor returned by the DB driver will be converted to a sequence of dictionaries keyed with the db field names. Results returned with as_dict=True are the same as those returned when applying .to_list() to a DAL query. If "as_ordered_dict"=True the behaviour is the same as when "as_dict"=True with the keys (field names) guaranteed to be in the same order as returned by the select name executed on the database. fields: list of DAL Fields that match the fields returned from the DB. The Field objects should be part of one or more Table objects defined on the DAL object. The "fields" list can include one or more DAL Table objects in addition to or instead of including Field objects, or it can be just a single table (not in a list). In that case, the Field objects will be extracted from the table(s). Note: if either `fields` or `colnames` is provided, the results will be converted to a DAL `Rows` object using the `db._adapter.parse()` method colnames: list of field names in tablename.fieldname format Note: It is also possible to specify both "fields" and the associated "colnames". In that case, "fields" can also include DAL Expression objects in addition to Field objects. For Field objects in "fields", the associated "colnames" must still be in tablename.fieldname format. For Expression objects in "fields", the associated "colnames" can be any arbitrary labels. DAL Table objects referred to by "fields" or "colnames" can be dummy tables and do not have to represent any real tables in the database. Also, note that the "fields" and "colnames" must be in the same order as the fields in the results cursor returned from the DB.

DAL.executesql.im_self <type 'NoneType'> belongs to class <type 'NoneType'>