Cat Feeder  1.0.0
The Cat feeder project
Loading...
Searching...
No Matches
sql_constants.py
Go to the documentation of this file.
1r"""
2# +==== BEGIN CatFeeder =================+
3# LOGO:
4# ..............(..../\
5# ...............)..(.')
6# ..............(../..)
7# ...............\‍(__)|
8# Inspired by Joan Stark
9# source https://www.asciiart.eu/
10# animals/cats
11# /STOP
12# PROJECT: CatFeeder
13# FILE: sql_constants.py
14# CREATION DATE: 11-10-2025
15# LAST Modified: 14:52:9 19-12-2025
16# DESCRIPTION:
17# This is the backend server in charge of making the actual website work.
18# /STOP
19# COPYRIGHT: (c) Cat Feeder
20# PURPOSE: File in charge of storing information that is required for the sql library, but is constant.
21# // AR
22# +==== END CatFeeder =================+
23
24"""
25
26from typing import List, Dict
27
28# Constants for supported database targets.
29TARGET: Dict[str, bool] = {
30 "mysql": True,
31 "mariadb": True,
32 "sqlite": False,
33 "postgresql": False,
34 "sqlexpress": False,
35 "microsoft sql server": False
36}
37
38# Arguments to remove if empty or None.
39UNWANTED_ARGUMENTS = [
40 "option_files"
41]
42
43# Keywords considered risky for SQL sanitization.
44RISKY_KEYWORDS: List[str] = [
45 'add', 'all', 'alter', 'analyze', 'as', 'asc', 'asensitive', 'before',
46 'bigint', 'binary', 'blob', 'by', 'call', 'cascade', 'case', 'change', 'char',
47 'character', 'check', 'collate', 'column', 'condition', 'constraint', 'continue',
48 'convert', 'create', 'cross', 'cursor', 'database', 'databases', 'day_hour',
49 'day_microsecond', 'day_minute', 'day_second', 'dec', 'decimal', 'declare', 'default',
50 'delayed', 'delete', 'desc', 'describe', 'deterministic', 'distinctrow', 'div', 'double', 'drop',
51 'dual', 'each', 'else', 'elseif', 'exit', 'explain',
52 'fetch', 'float', 'for', 'foreign', 'from', 'fulltext', 'general',
53 'grant', 'group', 'high_priority', 'hour_microsecond', 'hour_minute',
54 'hour_second', 'if', 'ignore', 'index', 'infile', 'inner', 'inout',
55 'insensitive', 'insert', 'int', 'integer', 'interval', 'into', 'iterate',
56 'key', 'keys', 'kill', 'leave', 'left', 'linear', 'lines',
57 'load', 'localtime', 'localtimestamp', 'lock', 'long', 'longblob', 'longtext', 'loop',
58 'low_priority', 'master_ssl_verify_server_cert', 'match', 'maxvalue', 'mediumblob',
59 'mediumint', 'mediumtext', 'middleint', 'minute_microsecond', 'minute_second',
60 'modifies', 'natural', 'no_write_to_binlog', 'numeric', 'on', 'optimize',
61 'option', 'optionally', 'order', 'out', 'outer', 'outfile', 'precision', 'primary',
62 'procedure', 'purge', 'range', 'read', 'reads', 'read_write', 'real', 'references',
63 'release', 'rename', 'repeat', 'replace', 'require', 'resignal', 'restrict',
64 'return', 'revoke', 'right', 'schema', 'schemas', 'second_microsecond',
65 'select', 'sensitive', 'separator', 'set', 'show', 'signal', 'smallint', 'spatial',
66 'specific', 'sql', 'sqlexception', 'sqlstate', 'sqlwarning', 'sql_big_result',
67 'sql_calc_found_rows', 'sql_small_result', 'ssl', 'straight_join',
68 'table', 'then', 'tinyblob', 'tinyint', 'tinytext', 'to',
69 'trigger', 'undo', 'unique', 'unlock', 'update', 'usage',
70 'use', 'using', 'values', 'varbinary', 'varchar', 'varcharacter',
71 'when', 'where', 'while', 'with', 'write', 'year_month'
72]
73
74# Logical gates used in SQL queries.
75KEYWORD_LOGIC_GATES: List[str] = [
76 'and', 'or', 'not', 'xor', 'between', 'in', 'is', 'like', 'regexp', 'rlike',
77 # 'null',
78 'true', 'false', 'exists',
79 'distinct', 'limit', 'having', 'join', 'union', 'current_date', 'current_time', 'current_timestamp', 'utc_date',
80 'utc_time', 'utc_timestamp', 'mod', 'if'
81]
82
83# Date format constants.
84DATE_ONLY: str = '%Y-%m-%d'
85DATE_AND_TIME: str = '%Y-%m-%d %H:%M:%S'
86
87# Error messages for database operations.
88CONNECTION_FAILED: str = "Connection to the database is non-existent, aborting command."
89CURSOR_FAILED: str = "Cursor to the database is non-existent, aborting command."
90
91# Specific error codes.
92GET_TABLE_SIZE_ERROR: int = -1
93
94# Risky SQL DDL trigger keywords.
95SQL_RISKY_DDL_TRIGGER_KEYWORDS: List[str] = [
96 "drop ", "alter ", "truncate ", "create database",
97 "use ", "grant ", "revoke ", "load data", "outfile", "infile"
98]