Terarea  2
The automation project
Loading...
Searching...
No Matches
src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions Class Reference
Collaboration diagram for src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions:
Collaboration graph

Public Member Functions

None __init__ (self, int success=0, int error=84, bool debug=False)
 
str protect_sql_cell (self, str cell)
 
Union[List[str], str] escape_risky_column_names (self, Union[List[str], str] columns)
 
Union[List[str], str] escape_risky_column_names_where_mode (self, Union[List[str], str] columns)
 
str check_sql_cell (self, str cell)
 
Union[List[Dict[str, Any]], int] beautify_table (self, List[str] column_names, List[List[Any]] table_content)
 
str compile_update_line (self, List line, List column, int column_length)
 
str process_sql_line (self, List[str] line, List[str] column, int column_length=(-1))
 

Data Fields

int error = error
 
bool debug = debug
 
int success = success
 
Disp disp
 
List[str] risky_keywords = SCONST.RISKY_KEYWORDS
 
List[str] keyword_logic_gates = SCONST.KEYWORD_LOGIC_GATES
 
SQLTimeManipulation sql_time_manipulation
 
str risky_keywords = f"`{key}`={value}"
 

Protected Member Functions

str _protect_value (self, str value)
 

Detailed Description

_summary_

Definition at line 13 of file sql_sanitisation_functions.py.

Constructor & Destructor Documentation

◆ __init__()

None src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.__init__ ( self,
int success = 0,
int error = 84,
bool debug = False )
_summary_
    This is the class that contains functions in charge of sanitising sql queries.

Args:
    debug (bool, optional): _description_. Defaults to False.: enable debug mode

Definition at line 17 of file sql_sanitisation_functions.py.

Member Function Documentation

◆ _protect_value()

str src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions._protect_value ( self,
str value )
protected
Ensures the value is safely passed as a string in an SQL query.
It wraps the value in single quotes and escapes any single quotes within the value.

Args:
    value (str): The value that needs to be protected.

Returns:
    str: The value with protection applied, safe for SQL queries.

Definition at line 104 of file sql_sanitisation_functions.py.

◆ beautify_table()

Union[List[Dict[str, Any]], int] src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.beautify_table ( self,
List[str] column_names,
List[List[Any]] table_content )
_summary_
    Convert the table to an easier version for navigating.

Args:
    column_names (List[str]): _description_
    table_content (List[List[Any]]): _description_

Returns:
    Union[List[Dict[str, Any]], int]: _description_: the formated content or self.error if an error occured.

Definition at line 237 of file sql_sanitisation_functions.py.

◆ check_sql_cell()

str src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.check_sql_cell ( self,
str cell )
_summary_
    Check if the cell is a string or a number.

Args:
    cell (str): _description_

Returns:
    str: _description_

Definition at line 208 of file sql_sanitisation_functions.py.

◆ compile_update_line()

str src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.compile_update_line ( self,
List line,
List column,
int column_length )
_summary_
    Compile the line required for an sql update to work.

Args:
    line (List): _description_
    column (List): _description_
    column_length (int): _description_

Returns:
    str: _description_

Definition at line 283 of file sql_sanitisation_functions.py.

◆ escape_risky_column_names()

Union[List[str], str] src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.escape_risky_column_names ( self,
Union[List[str], str] columns )
_summary_
    Escape the risky column names.

Args:
    columns (List[str]): _description_

Returns:
    List[str]: _description_

Definition at line 65 of file sql_sanitisation_functions.py.

◆ escape_risky_column_names_where_mode()

Union[List[str], str] src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.escape_risky_column_names_where_mode ( self,
Union[List[str], str] columns )
Escape the risky column names in where mode, except for those in keyword_logic_gates.

Args:
    columns (Union[str, List[str]]): Column names to be processed.

Returns:
    Union[List[str], str]: Processed column names with risky ones escaped.

Definition at line 160 of file sql_sanitisation_functions.py.

◆ process_sql_line()

str src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.process_sql_line ( self,
List[str] line,
List[str] column,
int column_length = (-1) )
_summary_
    Convert a List of strings to an sql line so that it can be inserted into a table.

Args:
    line (List[str]): _description_

Returns:
    str: _description_

Definition at line 308 of file sql_sanitisation_functions.py.

◆ protect_sql_cell()

str src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.protect_sql_cell ( self,
str cell )
_summary_
    This is a function in charge of cleaning by nullifying (escaping) characters that could cause the sql command to break.

Args:
    cells (str): _description_: The cell to be checked

Returns:
    str: _description_: A (hopfully) clean string.

Definition at line 43 of file sql_sanitisation_functions.py.

Field Documentation

◆ debug

bool src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.debug = debug

Definition at line 25 of file sql_sanitisation_functions.py.

◆ disp

Disp src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.disp
Initial value:
= Disp(
TOML_CONF,
SAVE_TO_FILE,
FILE_NAME,
debug=self.debug,
logger=self.__class__.__name__
)

Definition at line 28 of file sql_sanitisation_functions.py.

◆ error

int src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.error = error

Definition at line 24 of file sql_sanitisation_functions.py.

◆ keyword_logic_gates

List[str] src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.keyword_logic_gates = SCONST.KEYWORD_LOGIC_GATES

Definition at line 37 of file sql_sanitisation_functions.py.

◆ risky_keywords [1/2]

str src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.risky_keywords = SCONST.RISKY_KEYWORDS

Definition at line 36 of file sql_sanitisation_functions.py.

◆ risky_keywords [2/2]

str src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.risky_keywords = f"`{key}`={value}"

Definition at line 85 of file sql_sanitisation_functions.py.

◆ sql_time_manipulation

SQLTimeManipulation src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.sql_time_manipulation
Initial value:
= SQLTimeManipulation(
self.debug
)

Definition at line 39 of file sql_sanitisation_functions.py.

◆ success

int src.lib.sql.sql_sanitisation_functions.SQLSanitiseFunctions.success = success

Definition at line 26 of file sql_sanitisation_functions.py.


The documentation for this class was generated from the following file: