ControllerDatabase module

class controllers.controller_database.ControllerDatabase(db_name: str, sql_file_name: str = 'data_model_table_create.sql')

Bases: object

Class responsible for managing the database

fetch_all_results_from_last_query()List[Any]

Fetch all results from the last query

Returns

List of any

fetch_one_result_from_last_query()Any

Fetch one result from the last query

Returns

Any

fetch_some_results_from_last_query(number_of_queries: int = 5)List[Any]

Fetch some results from last query

Parameters

number_of_queries – the number of results to be fetched

Returns

List of any

init: bool = False
static initialize(db_name: str, sql_file_path: str)bool

Responsible for initializng the database

Parameters
  • db_name – the name of the database

  • sql_file_path – the database path

Returns

bool

run_query(query: str)

Runs a query

Parameters

query – the sql query to be runned

Returns

None

run_query_with_args(query: str, args: dict)

Runs a query with arguments

Parameters
  • query – the sql query to be runned

  • args – the query arguments

Returns

None

save_changes()

Save changes to the database

Returns

None