The seedbox.db.base Module

Abstract class representing the required capabilities of a database API.

class seedbox.db.base.Connection(conf)

Bases: object

Base class for database connections.

Initializes new instance.

Parameters:conf (oslo_config.cfg.ConfigOpts) – an instance of configuration file
backup()

Backup database.

bulk_create(instances)

Save the instances in bulk to the database.

Parameters:instances – a list of instance of modeled data object
bulk_update(value_map, entity_type, qfilter)

Save the updated instances in bulk to the database.

Parameters:
  • value_map – a dict of key-value pairs representing the data of an instance.
  • entity_type – the model type
  • qfilter – query filter to determine which rows to update
clear()

Clear database.

delete(instance)

Delete the instance(s) based on filter from the database.

Parameters:instance – an instance of modeled data object
delete_by(entity_type, qfilter)

Delete instances of a specific type based on filter criteria

Parameters:
  • entity_type – the model type
  • qfilter – query filter to determine which rows to update
fetch(entity_type, pk)

Fetch the instance(s) based on filter from the database.

Parameters:
  • entity_type – the model type
  • pk – primary key value
fetch_by(entity_type, qfilter)

Fetch the instance(s) based on filter from the database.

Parameters:
  • entity_type – the model type
  • qfilter – query filter to determine which rows to update
save(instance)

Save the instance to the database.

Parameters:instance – an instance of modeled data object
shrink_db()

Shrink database.

upgrade()

Migrate the database to version or most recent version.