get_settings

This commit is contained in:
vok1no 2025-10-22 05:33:07 +03:00
parent 65132e1017
commit 651c16558c
2 changed files with 39 additions and 3 deletions

View File

@ -1,5 +1,5 @@
from settings.logger import log_function_call, logger
from utils import sql_insert
from utils import sql_insert, sql_select
class MAIN_FUNC:
@ -17,6 +17,29 @@ class MAIN_FUNC:
print(e)
return False
@log_function_call
def get_settings(self):
t = 'SELECT * FROM main_settings'
try:
res = sql_select(t)
return res
except SystemError as e:
print(e)
return False
@log_function_call
def get_setting(self, name):
id = -1
if isinstance(name, (int)):
id = int(name)
t = 'SELECT * FROM main_settings WHERE name = %s OR id = %s'
v = (name, id)
try:
res = sql_select(t, v)
return res[0][2]
except SystemError as e:
print(e)
return False
logger.info('START | 3/4 | Load main_func')
main_func = MAIN_FUNC()

View File

@ -1,5 +1,6 @@
from utils import *
from main_func import main_func
import time
data = {
'page': 'testing',
@ -7,4 +8,16 @@ data = {
'data': (1, 23, 'vok1no', (1, 2, 3))
}
r = main_func.create_log(data)
d = main_func.get_settings()
print(d)
print(r)
c = main_func.get_setting('debug_log_type')
print(c)
if c == 1:
logger.info(f'DEBUG_LOG_TYPE -> {c} | Включение режима!')
interval = 2 # интервал в секундах
while True:
print(f"DEBUG_LOG: Сейчас {time.ctime()}")
time.sleep(2)
else:
logger.info(f'DEBUG_LOG_TYPE -> {c} | Без включения!')