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

Class Table

source code

object --+
         |
        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) source code
 
_enable_record_versioning(self, archive_db=None, archive_name='%(tablename)s_archive', is_active='is_active', current_record='current_record', current_record_label=None) source code
 
_validate(self, **vars) source code
 
_create_references(self) source code
 
_filter_fields(self, record, id=False) source code
 
_build_query(self, key)
for keyed table only
source code
 
__getitem__(self, key) source code
 
__call__(self, key=<function <lambda> at 0x4068140>, **kwargs) source code
 
__setitem__(self, key, value) source code
 
__getattr__(self, key) source code
 
__setattr__(self, key, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
__delitem__(self, key) source code
 
__contains__(self, key) source code
 
has_key(self, key) source code
 
items(self) source code
 
__iter__(self) source code
 
iteritems(self) 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=False) source code
 
_attempt_upload(self, fields) source code
 
_defaults(self, fields)
If there are no fields/values specified, return table defaults
source code
 
_insert(self, **fields) source code
 
insert(self, **fields) source code
 
validate_and_insert(self, **fields) source code
 
validate_and_update(self, _key=<function <lambda> at 0x4068140>, **fields) source code
 
update_or_insert(self, _key=<function <lambda> at 0x4068140>, **values) source code
 
validate_and_update_or_insert(self, _key=<function <lambda> at 0x4068140>, **fields) source code
 
bulk_insert(self, items)
here items is a list of dictionaries
source code
 
_truncate(self, mode=None) source code
 
truncate(self, mode=None) source code
 
import_from_csv_file(self, csvfile, id_map=None, null='<NULL>', unique='uuid', id_offset=None, *args, **kwargs)
Import records from csv file.
source code
 
as_dict(self, flat=False, sanitize=True) source code
 
as_xml(self, sanitize=True) source code
 
as_json(self, sanitize=True) source code
 
as_yaml(self, sanitize=True) source code
 
with_alias(self, alias) source code
 
on(self, query) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __sizeof__, __subclasshook__

Properties [hide private]
  fields
  sqlsafe
  sqlsafe_alias

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.

Overrides: object.__init__

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

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

import_from_csv_file(self, csvfile, id_map=None, null='<NULL>', unique='uuid', id_offset=None, *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)
'restore' argument is default False;
    if set True will remove old values in table first.
'id_map' if set to None will not map ids.
The import will keep the id numbers in the restored table.
This assumes that there is an field of type id that
is integer and in incrementing order.
Will keep the id numbers in restored table.


Property Details [hide private]

fields

Get Method:
unreachable.fields(self)

sqlsafe

Get Method:
unreachable.sqlsafe(self)

sqlsafe_alias

Get Method:
unreachable.sqlsafe_alias(self)