module sql.database_object

Inheritance diagram of pyensae.sql.database_object

Short summary

module pyensae.sql.database_object

Database

source on GitHub

Classes

class

truncated documentation

DatabaseObject

Methods for database related to object, see Database.

Methods

method

truncated documentation

enumerate_objects

Iterator on objects assuming each row of a table is a object (classObject type). The classObject must have the following …

fill_table_with_objects

Fill a table of a database with object (from iterator_on) following the interface:

Documentation

Database

source on GitHub

class pyensae.sql.database_object.DatabaseObject

Bases: object

Methods for database related to object, see Database.

source on GitHub

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 schema

  • the 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):

#…

source on GitHub

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 schema

  • a property asrow which puts all values in a row

  • a property index which precises the index to unless it returns None

  • a 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).

source on GitHub