mewlo.mpacks.core.database.mdbmanager_sqlalchemy module

dbmanager_sqlalchemy.py

This is our database helper module

class mewlo.mpacks.core.database.mdbmanager_sqlalchemy.DbmSqlAlchemyHelper(dbmanager, dbsettings)[source]

Bases: object

Helper for MewloDatabaseManagerSqlA that holds engine, metadata, session, connection, data. We can have multiple DbmSqlAlchemyHelper’s, so that some models can be using some databases, and some using others. We use the concept of ‘schema’ to group models with different database setups (DbmSqlAlchemyHelper’s). Each model class also caches a reference to the DbmSqlAlchemyHelper that manages the class.

dbcommit()[source]

Flush and commit db if appropriate. sqlalchemy does flush as part of commit.

dbflush()[source]

Flush db if appropriate (less than commit).

ensurecreate()[source]

Do nothing?

getmake_connection()[source]

Return self.connection or create it if None.

getmake_engine()[source]

Return self.engine or create it if None.

getmake_metadata()[source]

To make metadata we just call make engine.

getmake_session()[source]

Return self.session or create it if None.

resolve(text)[source]
shutdown()[source]

Shutdown any sqlalchemy stuff.

sqlahelper_makedbtable_one(tablename)[source]
sqlahelper_makedbtables_all()[source]
class mewlo.mpacks.core.database.mdbmanager_sqlalchemy.MewloDatabaseManagerSqlA(mewlosite, debugmode)[source]

Bases: mewlo.mpacks.core.database.mdbmanager.MewloDatabaseManager

Derived DatabaseManager class built for sqlalchemy.

UNUSED_flush_all_dbs()[source]

Ask all helpers to flush.

UNUSED_flushdb_on_request_ends()[source]

Flush any sessions.

build_filter_from_inlist(key, vallist)[source]

Build a filter when we have a list. This should ONLY be called when we know val is a non-empty list

build_querystrlist(keydict)[source]

Build a list of query strings for each item of keydict; each value in keydict may map to a list of acceptable items

combine_querystr_from_querystrlist(allquerystrs, combinestr)[source]

Combine query string claues with AND or OR. Return None if empty.

commit_all_dbs()[source]

Ask all helpers to flush.

commitdb_on_request_ends()[source]

Flush any sessions.

convertwhereclause(whereclause)[source]

Convert to a text clause if it’s text.

escapequote_stringval_for_sql(val)[source]

Wrap val in double quote and escape it.

filter_query_advanced(query, keydict)[source]

Build and attach filters for a query based on a dictionary keydict that may have LISTS as values.

filter_query_bycnfkeys(query, cnflist)[source]

Build and attach filters for a query based on a dictionary keydict that may have LISTS as values.

get_modelclass_dbsession(modelclass)[source]

Shortcut to get info from class object.

get_sqlahelper(idname)[source]

Lookup the DbmSqlAlchemyHelper object based on the id given, creating engine/session if its first time.

make_disjunctclause(disjunction_keydict)[source]

Return a disjunctive clause for later recombination as part of a DNF or CNF expression.

makedbtable_one(tablename)[source]
makedbtables_all()[source]

Ask sqlalchemy to build the actual tables for the models that have been created so-far. NOTE: we may call this more than once; once initially for some early models we need, and then later after startup completes.

model_delete(modelobj)[source]

Delete the model object.

model_save(modelobj)[source]

Save the model object.

model_sessionflush(modelobj)[source]

Flush the session associated with model.

modelclass_delete_all_bywhereclause(modelclass, whereclause)[source]

Delete all using using a where clause.

modelclass_delete_bykey(modelclass, keydict)[source]

Delete all items (rows) matching key dictionary settings.

modelclass_deleteall(modelclass)[source]

Delete all items (rows) in the table.

modelclass_find_all(modelclass)[source]

Load all rows and return them as array.

modelclass_find_all_advanced(modelclass, keydict)[source]

Find and return all rows specified by keydict. the keydict MIGHT specify a LIST for each dictionary value

modelclass_find_all_bycnf(modelclass, cnflist)[source]

Find and return all rows specified by keydict. the keydict MIGHT specify a LIST for each dictionary value

modelclass_find_all_bykey(modelclass, keydict)[source]

Find and return all objects specified by keydict.

modelclass_find_one_bykey(modelclass, keydict, defaultval=None)[source]

Find and return an instance object for the single row specified by keydict. :return: defaultval if not found

modelclass_find_one_byprimaryid(modelclass, primaryid, defaultval=None)[source]

Find and return an instance object for the single row specified by keydict. :return: defaultval if not found

modelclass_find_one_bywhereclause(modelclass, whereclause, defaultval=None)[source]

Find using a where clause.

modelclass_update_all_dict_bywhereclause(modelclass, updatedict, whereclause)[source]

Update all with dictionary using a where clause.

set_sqlalchemydebuglevel(level)[source]

Helper to set debugging level of sql alchemy.

setup_logcatchers()[source]

Catch sqlalchemy log statements and route to Mewlo.

setup_sqlahelpers(eventlist)[source]
shutdown()[source]
sqlalchemydebuglevel_donetemporarydisable()[source]

Helper to set debugging level of sql alchemy.

sqlalchemydebuglevel_temporarydisable()[source]

Helper to set debugging level of sql alchemy.

startup_prep(stageid, eventlist)[source]

This is invoked by site strtup, for each stage specified in startup_stages_needed() above.

Table Of Contents

Previous topic

mewlo.mpacks.core.database.mdbmanager module

Next topic

mewlo.mpacks.core.database.mdbmixins module

This Page