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- 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_funcforce – 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
- reset_connection()¶
Trip the
connection_parameters_changedflag. Nextconnectcall with use the new values