Package web2py :: Package gluon :: Module dal :: Class Table
[hide private]
[frames] | no frames]

Class Table

source code

object --+    
         |    
      dict --+
             |
            Table

an instance of this class represents a database table

Example:
   db = DAL(...)
   db.define_table('users', Field('name'))
   db.users.insert(name='me') # print db.users._insert(...) to see SQL
   db.users.drop()


Instance Methods [hide private]
 
__init__(self, db, tablename, *fields, **args)
Initializes the table and performs checking on the provided fields.
source code
 
_validate(self, **vars) source code
 
_create_references(self) source code
 
_filter_fields(self, record, id=True) source code
 
_build_query(self, key)
for keyed table only
source code
 
__getitem__(self, key)
x[y]
source code
 
__call__(self, key=<function <lambda> at 0xd1ec80>, **kwargs) source code
 
__setitem__(self, key, value)
x[i]=y
source code
 
__delitem__(self, key)
del x[y]
source code
 
__getattr__(self, key) source code
 
__setattr__(self, key, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
__iter__(self)
iter(x)
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code
 
_drop(self, mode='') source code
 
drop(self, mode='') source code
 
_listify(self, fields, update=True) source code
 
_insert(self, **fields) source code
 
insert(self, **fields) source code
 
validate_and_insert(self, **fields) source code
 
update_or_insert(self, key=<function <lambda> at 0xd1ec80>, **values) source code
 
bulk_insert(self, items)
here items is a list of dictionaries
source code
 
_truncate(self, mode=1) source code
 
truncate(self, mode=1) source code
 
import_from_csv_file(self, csvfile, id_map=1, null='<NULL>', unique='uuid', *args, **kwargs)
import records from csv file.
source code
 
with_alias(self, alias) source code
 
on(self, query) source code

Inherited from dict: __cmp__, __contains__, __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__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, db, tablename, *fields, **args)
(Constructor)

source code 

Initializes the table and performs checking on the provided fields.

Each table will have automatically an 'id'.

If a field is of type Table, the fields (excluding 'id') from that table will be used instead.

:raises SyntaxError: when a supplied field is of incorrect type.
Returns:
new empty dictionary

Overrides: dict.__init__

__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)

__delitem__(self, key)
(Index deletion operator)

source code 
del x[y]
Overrides: dict.__delitem__
(inherited documentation)

__setattr__(self, key, value)

source code 
x.__setattr__('name', value) <==> x.name = value
Overrides: object.__setattr__
(inherited documentation)

__iter__(self)

source code 
iter(x)
Overrides: dict.__iter__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: dict.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

import_from_csv_file(self, csvfile, id_map=1, null='<NULL>', unique='uuid', *args, **kwargs)

source code 
import records from csv file. Column headers must have same names as table fields. field 'id' is ignored. If column names read 'table.file' the 'table.' prefix is ignored. 'unique' argument is a field which must be unique (typically a uuid field)