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

Class Rows

source code

object --+
         |
        Rows

A wrapper for the return value of a select. It basically represents a table. It has an iterator and each row is represented as a dictionary.

Instance Methods [hide private]
 
__init__(self, db=1, records=[], colnames=[], compact=True, rawrows=1)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
setvirtualfields(self, **keyed_virtualfields) source code
 
__and__(self, other) source code
 
__or__(self, other) source code
 
__nonzero__(self) source code
 
__len__(self) source code
 
__getslice__(self, a, b) source code
 
__getitem__(self, i) source code
 
__iter__(self)
iterator over records
source code
 
__str__(self)
serializes the table into a csv file
source code
 
first(self) source code
 
last(self) source code
 
find(self, f)
returns a new Rows object, a subset of the original object, filtered by the function f
source code
 
exclude(self, f)
removes elements from the calling Rows object, filtered by the function f, and returns a new Rows object containing the removed elements
source code
 
sort(self, f, reverse=True)
returns a list of sorted elements (not sorted in place)
source code
 
as_list(self, compact=True, storage_to_dict=True, datetime_to_str=True)
returns the data as a list or dictionary.
source code
 
as_dict(self, key='id', compact=True, storage_to_dict=True, datetime_to_str=True)
returns the data as a dictionary of dictionaries (storage_to_dict=True) or records (False)
source code
 
export_to_csv_file(self, ofile, null='<NULL>', *args, **kwargs)
export data to csv, the first line contains the column names...
source code
 
xml(self)
serializes the table using sqlhtml.SQLTABLE (if present)
source code
 
json(self, mode='object', default=1)
serializes the table to a JSON list of objects
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, db=1, records=[], colnames=[], compact=True, rawrows=1)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
serializes the table into a csv file
Overrides: object.__str__

as_list(self, compact=True, storage_to_dict=True, datetime_to_str=True)

source code 
returns the data as a list or dictionary. :param storage_to_dict: when True returns a dict, otherwise a list(default True) :param datetime_to_str: convert datetime fields as strings (default True)

as_dict(self, key='id', compact=True, storage_to_dict=True, datetime_to_str=True)

source code 

returns the data as a dictionary of dictionaries (storage_to_dict=True) or records (False)

:param key: the name of the field to be used as dict key, normally the id :param compact: ? (default True) :param storage_to_dict: when True returns a dict, otherwise a list(default True) :param datetime_to_str: convert datetime fields as strings (default True)

export_to_csv_file(self, ofile, null='<NULL>', *args, **kwargs)

source code 

export data to csv, the first line contains the column names

:param ofile: where the csv must be exported to
:param null: how null values must be represented (default '<NULL>')
:param delimiter: delimiter to separate values (default ',')
:param quotechar: character to use to quote string values (default '"')
:param quoting: quote system, use csv.QUOTE_*** (default csv.QUOTE_MINIMAL)
:param represent: use the fields .represent value (default False)
:param colnames: list of column names to use (default self.colnames)
                 This will only work when exporting rows objects!!!!
                 DO NOT use this with db.export_to_csv()