Skip to content

DataBaseController Module

DataBaseController

Controller class for managing SQLite database connections and queries.

Attributes:

Name Type Description
app_db Connection

The SQLite database connection object.

app_cursor Cursor

The cursor object for executing SQL queries.

Source code in GameFrame/DataBaseController.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class DataBaseController:
    """
    Controller class for managing SQLite database connections and queries.

    Attributes:
        app_db (sqlite3.Connection): The SQLite database connection object.
        app_cursor (sqlite3.Cursor): The cursor object for executing SQL queries.
    """

    def __init__(self, dbase_file_name: str):
        """
        Initializes the DataBaseController with the specified database file.

        Args:
            dbase_file_name (str): The name of the SQLite database file.
        """
        app_file_path = os.path.join(os.path.dirname(__file__), dbase_file_name)
        self.app_db = sqlite3.connect(app_file_path)
        self.app_cursor = self.app_db.cursor()

    def close(self):
        """
        Closes the database connection.
        """
        self.app_db.close()

__init__(dbase_file_name)

Initializes the DataBaseController with the specified database file.

Parameters:

Name Type Description Default
dbase_file_name str

The name of the SQLite database file.

required
Source code in GameFrame/DataBaseController.py
14
15
16
17
18
19
20
21
22
23
def __init__(self, dbase_file_name: str):
    """
    Initializes the DataBaseController with the specified database file.

    Args:
        dbase_file_name (str): The name of the SQLite database file.
    """
    app_file_path = os.path.join(os.path.dirname(__file__), dbase_file_name)
    self.app_db = sqlite3.connect(app_file_path)
    self.app_cursor = self.app_db.cursor()

close()

Closes the database connection.

Source code in GameFrame/DataBaseController.py
25
26
27
28
29
def close(self):
    """
    Closes the database connection.
    """
    self.app_db.close()