poppy.core.db.handlers module

poppy.core.db.handlers.load_databases(databases)[source]

Load databases according to the information provided in the dictionary in argument.

Given a list of databases with their properties in a dictionary, create the connectors if not already created.

poppy.core.db.handlers.yield_limit(qry, pk_attr, maxrq=1000)[source]

Specialized windowed query generator (using LIMIT/OFFSET)

This recipe is to select through a large number of rows thats too large to fetch at once. The technique depends on the primary key of the FROM clause being an integer value, and selects items using LIMIT.

poppy.core.db.handlers.connect_databases()[source]

Make a connection and reflection of databases registered.

poppy.core.db.handlers.get_or_create(session, model, create_method='', create_method_kwargs=None, **kwargs)[source]

Simply get an object if already present in the database or create it in the other case. See http://skien.cc/blog/2014/01/15/sqlalchemy-and-race-conditions-implementing/ and http://skien.cc/blog/2014/02/06/sqlalchemy-and-race-conditions-follow-up/ for better details on why this function as been upgraded to the provided example. Better handling of weird cases in the situation of multiple processes using the database at the same time.

poppy.core.db.handlers.get_or_create_with_info(session, model, create_method='', create_method_kwargs=None, **kwargs)[source]

Simply get an object if already present in the database or create it in the other case. See http://skien.cc/blog/2014/01/15/sqlalchemy-and-race-conditions-implementing/ and http://skien.cc/blog/2014/02/06/sqlalchemy-and-race-conditions-follow-up/ for better details on why this function as been upgraded to the provided example. Better handling of weird cases in the situation of multiple processes using the database at the same time.

poppy.core.db.handlers.create(session, model, **kwargs)[source]

Simply create an object and add it into the database.

poppy.core.db.handlers.update_one(session, model, values, **kwargs)[source]

Update column values of a single entry in the database.