__init__

GenericDBWrapper.__init__(db=None, connector_func: callable = None, **kwargs)[source]

Initialise the database wrapper class.

This constructor sets _conn to None, and sets up various instance variables such as connector_func and query_mode.

While you can set various instance variables such as query_mode via this constructor, if you’re inheriting this class, it’s recommended that you override the DEFAULT_ static class attributes to your preference.

Parameters
  • db (str) – The name / path of the database to connect to

  • connector_func (callable) – A function / method / lambda which returns a database connection object which acts like GenericConnection

Key bool auto_create_schema

(Default: True) If True, call create_schemas() during constructor.

Key list connector_args

A list of arguments to be passed as positional args to connector_func

Key dict connector_kwargs

A dict of arguments to passed as keyword args to connector_func

Key str query_mode

Either flat (return tuples) or dict (return dicts of column:value) Controls how results are returned from query functions, e.g. query() and fetch()

Key str table_query

The query used to check for existence of a table. The query should take one prepared statement argument (the table name to check for), and the first column returned must be named table_count - an integer containing how many tables were found under the given name (usually just 0 if not found, 1 if found).

Key str table_list_query

The query used to obtain a list of tables in the database. The query should take no arguments, and return rows containing one column each, name - the name of the table.