engforge.datastores.data.DBConnection

class DBConnection(*args, **kwargs)[source]

Bases: LoggingMixin

A database singleton that is thread safe and pickleable (serializable) to get the active instance use DBConnection.instance(**non_default_connection_args)

On the Singleton DBconnection.instance(): __init__(*args,**kwargs) will get called, technically you could do it this way but won’t be thread safe, or a single instance :type database_name: :param database_name: the name for the database inside the db server :type host: :param host: hostname :type user: :param user: username :type passd: :param passd: password :param port: hostname :param echo: if the engine echos or not

Methods

add_fields

Overwrite this to modify logging fields

change_all_log_lvl

cleanup_sessions

configure

A boilerplate configure method

critical

A routine to communicate to the root of the server network that there is an issue

debug

Writes at a low level to the log file.

ensure_database_exists

Check if database exists, if not create it and tables

error

Writes to log as a error

extract_message

filter

This acts as the interface for logging.Filter Don't overwrite this, use add_fields instead.

info

Writes to log but with info category, these are important typically and inform about progress of process in general

installSTDLogger

We only want std logging to start

message_with_identiy

converts to color and string via the termcolor library :type message: str :param message: a string convertable entity :type color: :param color: a color in [grey,red,green,yellow,blue,magenta,cyan,white]

msg

Writes to log.

rebuild_database

Rebuild database on confirmation, create the database if nessicary

resetLog

reset log

resetSystemLogs

resets log on all internal instance LoggingMixins

session_scope

Provide a transactional scope around a series of operations.

slack_notification

warning

Writes to log as a warning

Attributes

Session

connect_args

connection_string

dbname

echo

engine

host

identity

log_fmt

log_level

log_on

logger

max_overflow

passd

pool_size

port

scopefunc

session_factory

slack_webhook_url

user

add_fields(record)

Overwrite this to modify logging fields

configure()[source]

A boilerplate configure method

critical(*args)

A routine to communicate to the root of the server network that there is an issue

debug(*args)

Writes at a low level to the log file… usually this should be detailed messages about what exactly is going on

ensure_database_exists(create_meta=True)[source]

Check if database exists, if not create it and tables

error(error, msg='')

Writes to log as a error

filter(record)

This acts as the interface for logging.Filter Don’t overwrite this, use add_fields instead.

info(*args)

Writes to log but with info category, these are important typically and inform about progress of process in general

installSTDLogger()

We only want std logging to start

message_with_identiy(message, color=None)

converts to color and string via the termcolor library :type message: str :param message: a string convertable entity :type color: :param color: a color in [grey,red,green,yellow,blue,magenta,cyan,white]

Parameters:

message (str)

msg(*args, lvl=5)

Writes to log… this should be for raw data or something… least priorty

rebuild_database(confirm=True)[source]

Rebuild database on confirmation, create the database if nessicary

resetLog()

reset log

resetSystemLogs(reseted=None)

resets log on all internal instance LoggingMixins

session_scope()[source]

Provide a transactional scope around a series of operations.

warning(*args)

Writes to log as a warning