web2py.gluon.dal.Table

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
update(self, *args, **kwargs) Update D from E and F: for k in E: D[k] = E[k] (if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k] | 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 0xefc500>, **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 0xefc500>, **values) | source code
bulk_insert(self, items) here items is a list of dictionaries | source code
_truncate(self, mode=global_settings.applications_parent) | source code
truncate(self, mode=global_settings.applications_parent) | source code
import_from_csv_file(self, csvfile, id_map=global_settings.applications_parent, 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`, `values` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`

Properties | [hide private]
| fields
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__

### update(self, *args, **kwargs) | source code
  Update D from E and F: for k in E: D[k] = E[k] (if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k] Returns:
      None
Overrides: dict.update (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)

### __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=global_settings.applications_parent, 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)

Property Details | [hide private]

  ### fields Get Method: unreachable.fields(self) Set Method:
      global_settings.applications_parent
  - PyMySQL: A pure-Python drop-in replacement for MySQLdb. Delete Method:
      global_settings.applications_parent
- PyMySQL: A pure-Python drop-in replacement for MySQLdb.