module sql.database_object
¶
Short summary¶
module pyensae.sql.database_object
Database
Classes¶
class |
truncated documentation |
---|---|
Methods for database related to object, see |
Methods¶
method |
truncated documentation |
---|---|
Iterator on objects assuming each row of a table is a object (classObject type). The classObject must have the following … |
|
Fill a table of a database with object (from |
Documentation¶
- class pyensae.sql.database_object.DatabaseObject¶
Bases:
object
Methods for database related to object, see
Database
.- enumerate_objects(table, classObject)¶
Iterator on objects assuming each row of a table is a object (classObject type). The classObject must have the following properties:
a staticmethod
schema_database_read
which gives the schemathe constructor must accept a constructor where parameter have the same name as the column names
- Parameters:
table – table name
classObject – class object
- Returns:
iterator on object
Example:
- for blog in db.enumerate_objects (“blogs”, StreamRSS):
#…
- fill_table_with_objects(tablename, iterator_on, check_existence=False, skip_exception=False)¶
Fill a table of a database with object (from
iterator_on
) following the interface:a property
schema_database
which gives the schemaa property
asrow
which puts all values in a rowa property
index
which precises the index to unless it returns Nonea property
indexes
which precises other indexes to create (optional)
The property
asrow
must not include other objects, only their ids. If the table does not exists, it creates it.- Parameters:
tablename – name of a table (created if it does not exists)
iterator_on – iterator_on on StreamRSS object
check_existence – avoid adding an element if it already exists (based on the index columns)
skip_exception – skip exception while inserting an element
The function do not check duplicate among elements sent in
iterator_on
, it only checks duplicate between the new and the old ones (meaning in the database).