Package web2py :: Package gluon :: Module dal2 :: Class DAL
[hide private]
[frames] | no frames]

Class DAL

source code

object --+    
         |    
      dict --+
             |
            DAL

an instance of this class represents a database connection

Example:

  db = DAL('sqlite://test.db')
  db.define_table('tablename', Field('fieldname1'),
                               Field('fieldname2'))
Nested Classes [hide private]
  Field
an instance of this class represents a database field
  Table
an instance of this class represents a database table
Instance Methods [hide private]
new empty dictionary

__init__(self, uri='sqlite://dummy.db', pool_size=0, folder=None, db_codec='UTF-8')
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
define_table(self, tablename, *fields, **args) source code
 
__iter__(self)
iter(x)
source code
 
__getitem__(self, key)
x[y]
source code
 
__setitem__(self, key, value)
x[i]=y
source code
 
__getattr__(self, key) source code
 
__setattr__(self, key, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
__repr__(self)
repr(x)
source code
 
__call__(self, query=None) source code
 
commit(self) source code
 
rollback(self) source code
 
executesql(self, query, placeholders=None, as_dict=False)
placeholders is optional and will always be None when using DAL 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.
source code
 
_update_referenced_by(self, other) source code
 
export_to_csv_file(self, ofile, *args, **kwargs) source code
 
import_from_csv_file(self, ifile, id_map={}, null='<NULL>', unique='uuid', *args, **kwargs) source code

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __gt__, __hash__, __le__, __len__, __lt__, __ne__, __new__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __str__

Static Methods [hide private]
 
_set_thread_folder(folder)
# ## this allows gluon to comunite a folder for this thread # ## <<<<<<<<< Should go away as new DAL replaces old sql.py
source code
 
distributed_transaction_begin(*instances) source code
 
distributed_transaction_commit(*instances) source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, uri='sqlite://dummy.db', pool_size=0, folder=None, db_codec='UTF-8')
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Returns:
new empty dictionary

Overrides: object.__init__
(inherited documentation)

__iter__(self)

source code 

iter(x)

Overrides: dict.__iter__
(inherited documentation)

__getitem__(self, key)
(Indexing operator)

source code 

x[y]

Overrides: dict.__getitem__
(inherited documentation)

__setitem__(self, key, value)
(Index assignment operator)

source code 

x[i]=y

Overrides: dict.__setitem__
(inherited documentation)

__setattr__(self, key, value)

source code 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

executesql(self, query, placeholders=None, as_dict=False)

source code 

placeholders is optional and will always be None when using DAL 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.

Added 2009-12-05 "as_dict" optional argument. 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. Tested with SQLite but should work with any database since the cursor.description used to get field names is part of the Python dbi 2.0 specs. Results returned with as_dict = True are the same as those returned when applying .to_list() to a DAL query.

[{field1: value1, field2: value2}, {field1: value1b, field2: value2b}]

--bmeredyk