vantage6.backend.common.base.BaseDatabase#

class BaseDatabase#

Bases: object

Database class that is used to connect to the database and create the database session.

The database is created as a singleton, so that it can be destroyed (as opposed to a module). This is especially useful when creating unit tests in which we want fresh databases every now and then.

__init__()#

Methods

__init__()

add_col_to_table(column, table_cls)

Database operation to add column to Table

is_column_missing(column, column_names, ...)

Check if column is missing in the table

add_col_to_table(column, table_cls)#

Database operation to add column to Table

Parameters:
  • column (Column) – The SQLAlchemy model column that is to be added

  • table_cls (Table) – The SQLAlchemy table to which the column is to be added

Return type:

None

static is_column_missing(column, column_names, table_name)#

Check if column is missing in the table

Parameters:
  • column (Column) – The column that is evaluated

  • column_names (List[str]) – A list of all column names in the table

  • table_name (str) – The name of the table the column resides in

Returns:

True if column is not in the table or a parent table

Return type:

boolean