![]() |
Terarea
2
The automation project
|
Public Member Functions | |
None | __init__ (self, str url, int port, str username, str password, str db_name, int success=0, int error=84, bool debug=False) |
None | show_connection_info (self, str func_name="show_connection_info") |
int | initialise_pool (self) |
mysql.connector.pooling.PooledMySQLConnection | get_connection (self) |
mysql.connector.cursor.MySQLCursor | get_cursor (self, mysql.connector.pooling.PooledMySQLConnection connection) |
int | close_cursor (self, mysql.connector.cursor.MySQLCursor cursor) |
int | return_connection (self, mysql.connector.pooling.PooledMySQLConnection connection) |
int | destroy_pool (self) |
None | release_connection_and_cursor (self, Union[mysql.connector.pooling.PooledMySQLConnection, None] connection, Union[mysql.connector.pooling.PooledMySQLConnection, None] cursor=None) |
int | run_and_commit (self, str query, Union[mysql.connector.cursor.MySQLCursor, None] cursor=None) |
Union[int, Any] | run_and_fetch_all (self, str query, Union[mysql.connector.cursor.MySQLCursor, None] cursor=None) |
int | run_editing_command (self, str sql_query, str table, str action_type="update") |
None | __del__ (self) |
bool | is_pool_active (self) |
bool | is_connection_active (self, mysql.connector.pooling.PooledMySQLConnection connection) |
bool | is_cursor_active (self, mysql.connector.cursor.MySQLCursor cursor) |
Data Fields | |
int | error = error |
bool | debug = debug |
int | success = success |
str | url = url |
int | port = port |
str | username = username |
str | password = password |
str | db_name = db_name |
Disp | disp |
dict | pool_parameters |
Union[ | pool |
str | pool = "ProgrammingError: The pool could not be initialized." |
_summary_
Definition at line 16 of file sql_connections.py.
None src.lib.sql.sql_connections.SQLManageConnections.__init__ | ( | self, | |
str | url, | ||
int | port, | ||
str | username, | ||
str | password, | ||
str | db_name, | ||
int | success = 0, | ||
int | error = 84, | ||
bool | debug = False ) |
_summary_ This class is in charge of managing the connections to the sql database Args: url (str): _description_ port (int): _description_ username (str): _description_ password (str): _description_ db_name (str): _description_ succes (int, optional): _description_. Defaults to 0. error (int, optional): _description_. Defaults to 84. debug (bool, optional): _description_. Defaults to False.
Definition at line 20 of file sql_connections.py.
None src.lib.sql.sql_connections.SQLManageConnections.__del__ | ( | self | ) |
_summary_ Destructor
Definition at line 497 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.close_cursor | ( | self, | |
mysql.connector.cursor.MySQLCursor | cursor ) |
Closes the given cursor. Args: cursor (mysql.connector.cursor.MySQLCursor): The cursor to close.
Definition at line 194 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.destroy_pool | ( | self | ) |
_summary_ Destroy the connection pool. Returns: int: _description_
Definition at line 230 of file sql_connections.py.
mysql.connector.pooling.PooledMySQLConnection src.lib.sql.sql_connections.SQLManageConnections.get_connection | ( | self | ) |
_summary_ Retrieves a connection from the pool. Returns: mysql.connector.pooling.PooledMySQLConnection: _description_: A pooled connection
Definition at line 156 of file sql_connections.py.
mysql.connector.cursor.MySQLCursor src.lib.sql.sql_connections.SQLManageConnections.get_cursor | ( | self, | |
mysql.connector.pooling.PooledMySQLConnection | connection ) |
Retrieves a cursor from the given connection. Args: connection (mysql.connector.pooling.PooledMySQLConnection): The active connection. Returns: mysql.connector.cursor.MySQLCursor: The cursor object.
Definition at line 180 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.initialise_pool | ( | self | ) |
_summary_ Initialise a connection to the database (but within a pool) Raises: RuntimeError: _description_: A runtime error is raised if it fails. Returns: int: _description_: Returns self.success if the function succeeds.
Definition at line 89 of file sql_connections.py.
bool src.lib.sql.sql_connections.SQLManageConnections.is_connection_active | ( | self, | |
mysql.connector.pooling.PooledMySQLConnection | connection ) |
Checks if the connection is active. Args: connection (mysql.connector.pooling.PooledMySQLConnection): The connection to check. Returns: bool: True if the connection is active, False otherwise.
Definition at line 519 of file sql_connections.py.
bool src.lib.sql.sql_connections.SQLManageConnections.is_cursor_active | ( | self, | |
mysql.connector.cursor.MySQLCursor | cursor ) |
Checks if the cursor is active. Args: cursor (mysql.connector.cursor.MySQLCursor): The cursor to check. Returns: bool: True if the cursor is active, False otherwise.
Definition at line 544 of file sql_connections.py.
bool src.lib.sql.sql_connections.SQLManageConnections.is_pool_active | ( | self | ) |
_summary_ Check if the connection pool is active. Returns: bool: _description_
Definition at line 503 of file sql_connections.py.
None src.lib.sql.sql_connections.SQLManageConnections.release_connection_and_cursor | ( | self, | |
Union[mysql.connector.pooling.PooledMySQLConnection, None] | connection, | ||
Union[mysql.connector.pooling.PooledMySQLConnection, None] | cursor = None ) |
_summary_ Args: connection (Union[None]): _description_ cursor (Union[None]): _description_
Definition at line 246 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.return_connection | ( | self, | |
mysql.connector.pooling.PooledMySQLConnection | connection ) |
Returns a connection to the pool by closing it. Args: connection (mysql.connector.pooling.PooledMySQLConnection): The connection to close.
Definition at line 212 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.run_and_commit | ( | self, | |
str | query, | ||
Union[mysql.connector.cursor.MySQLCursor, None] | cursor = None ) |
Executes a query and commits changes. Args: cursor (mysql.connector.cursor.MySQLCursor): The active cursor. query (str): The query to execute.
Definition at line 263 of file sql_connections.py.
Union[int, Any] src.lib.sql.sql_connections.SQLManageConnections.run_and_fetch_all | ( | self, | |
str | query, | ||
Union[mysql.connector.cursor.MySQLCursor, None] | cursor = None ) |
Executes a query and fetches all results. Args: cursor (mysql.connector.cursor.MySQLCursor): The active cursor. query (str): The query to execute.
Definition at line 358 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.run_editing_command | ( | self, | |
str | sql_query, | ||
str | table, | ||
str | action_type = "update" ) |
_summary_ Function in charge of running the execute and making sure that the connection to the database is still valid. Args: command (str): _description_ Returns: int: _description_
Definition at line 471 of file sql_connections.py.
None src.lib.sql.sql_connections.SQLManageConnections.show_connection_info | ( | self, | |
str | func_name = "show_connection_info" ) |
Show the connection information
Definition at line 80 of file sql_connections.py.
str src.lib.sql.sql_connections.SQLManageConnections.db_name = db_name |
Definition at line 42 of file sql_connections.py.
bool src.lib.sql.sql_connections.SQLManageConnections.debug = debug |
Definition at line 36 of file sql_connections.py.
Disp src.lib.sql.sql_connections.SQLManageConnections.disp |
Definition at line 44 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.error = error |
Definition at line 35 of file sql_connections.py.
str src.lib.sql.sql_connections.SQLManageConnections.password = password |
Definition at line 41 of file sql_connections.py.
Union[ src.lib.sql.sql_connections.SQLManageConnections.pool |
Definition at line 75 of file sql_connections.py.
str src.lib.sql.sql_connections.SQLManageConnections.pool = "ProgrammingError: The pool could not be initialized." |
Definition at line 131 of file sql_connections.py.
dict src.lib.sql.sql_connections.SQLManageConnections.pool_parameters |
Definition at line 52 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.port = port |
Definition at line 39 of file sql_connections.py.
int src.lib.sql.sql_connections.SQLManageConnections.success = success |
Definition at line 37 of file sql_connections.py.
str src.lib.sql.sql_connections.SQLManageConnections.url = url |
Definition at line 38 of file sql_connections.py.
str src.lib.sql.sql_connections.SQLManageConnections.username = username |
Definition at line 40 of file sql_connections.py.