Database Package

class pychron.database.core.database_adapter.DatabaseAdapter(*args: Any, **kwargs: Any)[source]

The DatabaseAdapter is a base class for interacting with a SQLAlchemy database. Two main subclasses are used by pychron, IsotopeAdapter and MassSpecDatabaseAdapter.

This class provides attributes for describing the database url, i.e host, user, password etc, and methods for connecting and opening database sessions.

It also provides some helper functions used extensively by the subclasses, e.g. _add_item, _retrieve_items

commit()[source]

commit the session

connect(test=True, force=False, warn=True, version_warn=True, attribute_warn=False)[source]

Connect to the database

Parameters
  • test – Test the connection by running test_func

  • force – Test connection even if connection parameters haven’t changed

  • warn – Warn if the connection test fails

  • version_warn – Warn if database/pychron versions don’t match

Returns

True if connected else False

Return type

bool

create_all(metadata)[source]

Build a database schema with the current connection

Parameters

metadata – SQLAchemy MetaData object

flush()[source]

flush the session

get_migrate_version(**kw)[source]

Query the AlembicVersionTable

reset_connection()

Trip the connection_parameters_changed flag. Next connect call with use the new values

class pychron.database.core.database_adapter.SessionCTX(parent, use_parent_session=True)[source]