Table( tupleOfColNames, listOfRowTuples )
Tables are UserList objects, so you can iterate over them, access
rows by row number, take slices, etc. Each row is a dictionary-like
mapping object, with column names mapping to values. Mass SELECT ,
UPDATE , and DELETE operations are also available. Note that since
rows are mutable, modifying rows in row slices or SELECT slices will
modify the original table. DELETE , however, affects only the table
it is applied to. See the INSERT_ROWS method for an explanation of
the initial load format.
Methods
|
|
DELETE
INSERT
INSERT_ROWS
SELECT
SET
UPDATE
__init__
|
|
DELETE
|
DELETE ( self, whereItems )
table.DELETE(Items(field1=value1, field2=value2...))
Delete rows which match the field values asserted in the keyword
arguments. Affects only the specific table it is called upon.
|
|
INSERT
|
INSERT ( self, items )
table.INSERT(Items(field1=value1, field2=value2...))
Insert a row with the supplied field values. Affects only the
specific table it is called upon.
|
|
INSERT_ROWS
|
INSERT_ROWS (
self,
colNames,
rowList,
)
table.INSERT_ROWS(colnames tuple, rowlist)
Insert rowlist of tuples, where colNames is a tuple
containing the names of the columns used in the row tuples.
Example:
table.INSERT_ROWS(
('foo','bar','baz'), [
( 1, 2, 3),
( 4, 5, 6),
])
The above is equivalent to:
table.INSERT(foo=1,bar=2,baz=3)
table.INSERT(foo=4,bar=5,baz=6)
|
|
SELECT
|
SELECT ( self, whereItems )
table.SELECT(Items(field1=value1, field2=value2...)) -> Table slice
SELECT returns a new table which is the subset of rows from the
original table which match the field values asserted by the keyword
arguments to SELECT . You can then iterate over the new table, or
perform an UPDATE on it to make changes.
|
|
SET
|
SET (
self,
whereItems,
setItems,
)
table.SET( Items(key1=val1,...), Items(setfield1=setval1,...) )
Find a row matching whereItems and update it with the values in
setItems . If a matching row isn't found, insert a row
constructed from the fields in both whereItems and setItems .
|
|
UPDATE
|
UPDATE ( self, setItems )
table.UPDATE(Items(setCol1=setVal1, setCol2=setVal2...))
Sets the specified column values for all rows in the table.
This is most useful in conjunction with SELECT , e.g.:
table.SELECT(Items(foo=27)).UPDATE(Items(bar=50))
The above would set bar=50 on all rows of the original table
where the foo value was equal to 27. Note that updates
affect the value of rows in any tables that contain them, since
the row objects are shared between tables.
|
|
__init__
|
__init__ (
self,
colNames=(),
rowList=(),
rawData=None,
)
|
|