bout_runners.database.database_connector¶
Module containing the DatabaseBase class.
Classes
|
Class creating the database path and executing sql statements. |
-
class
bout_runners.database.database_connector.DatabaseConnector(name: Optional[str] = None, db_root_path: Optional[pathlib.Path] = None)[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
- __connectionConnection
Getter variable for connection
db_pathPathGet the properties of self.db_path.
connectionConnectionGet 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 or None
Name of the database (excluding .db) If set to None, the name of the caller directory will be used
- db_root_pathPath or str or None
Path to database If None is set, the path will be set to $HOME/BOUT_db
- Attributes
connectionGet the properties of self.connection.
db_pathGet the properties of self.db_path.
Methods
create_db_path(name, NoneType], …)Create the database path.
execute_statement(self, sql_statement, …)Execute a statement in the database.
-
property
connection¶ Get the properties of self.connection.
- Returns
- self.__connectionConnection
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: Union[str, NoneType], db_root_path: Union[pathlib.Path, NoneType]) → pathlib.Path[source]¶ Create the database path.
- Parameters
- namestr or None
Name of the database (excluding .db) If set to None, the name of the caller directory will be used
- db_root_pathPath or str or None
Path to database If None is set, the path will be set to $HOME/BOUT_db
- 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