bout_runners.database.database_connector

Module containing the DatabaseConnector class.

Classes

DatabaseConnector(name, db_root_path)

Class creating the database path and executing sql statements.

class bout_runners.database.database_connector.DatabaseConnector(name: str, db_root_path: pathlib.Path)[source]

Class creating the database path and executing sql statements.

Examples

>>> database = DatabaseConnector('test')
>>> database.execute_statement('CREATE TABLE my_table (col INT)')
Attributes
__db_pathNone or Path

Getter variable for db_path

__connectionsqlite3.Connection

Getter variable for connection

db_pathPath

Get the properties of self.db_path.

connectionsqlite3.Connection

Get the properties of self.connection.

Methods

create_db_path(name, db_root_path)

Create the database path

execute_statement(sql_statement, *parameters)

Execute a statement in the database

Set the path to the data base.

Parameters
namestr

Name of the database (excluding .db)

db_root_pathPath or str or None

Path to database

Attributes
connection

Get the properties of self.connection.

db_path

Get the properties of self.db_path.

Methods

create_db_path(name, db_root_path)

Create the database path.

execute_statement(sql_statement, *parameters)

Execute a statement in the database.

property connection

Get the properties of self.connection.

Returns
self.__connectionsqlite3.Connection

The connection to the database

Notes

To avoid corrupting data between databases, the setting this parameter outside the constructor is disabled

static create_db_path(name: Optional[str], db_root_path: pathlib.Path) → pathlib.Path[source]

Create the database path.

Parameters
namestr

Name of the database (excluding .db)

db_root_pathPath

Path to database

Returns
db_pathPath

Path to the database

property db_path

Get the properties of self.db_path.

Returns
self.__db_pathPath

Absolute path to the database

Notes

To avoid corrupting data between databases, the setting this parameter outside the constructor is disabled

execute_statement(sql_statement: str, *parameters) → None[source]

Execute a statement in the database.

Parameters
sql_statementstr

The statement execute

parameterstuple

Parameters used in .execute of the cursor (like )