This commit is contained in:
ada-dmitry
2023-08-22 15:47:26 +03:00
parent 8e05627782
commit c1ebc405d4
3 changed files with 20 additions and 16 deletions
+12 -10
View File
@@ -11,25 +11,27 @@ db_params = {
connection = psycopg2.connect(**db_params)
cursor = connection.cursor()
def query_ins_user(x, curs = cursor):
def query_ins_user(x, curs=cursor):
try:
# Запрос добавления пользователя
curs.execute(f"""INSERT into public.Users(TrueUserID, role, isAlive) values ({x}, 0)""")
curs.execute(
f"""INSERT into public.Users(TrueUserID, role, isAlive) values ({x}, 0)""")
curs.commit()
except Exception as e:
print("Ошибка:", e)
def query_ins_chat(x, curs = cursor):
try: # Запрос добавления чата
curs.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
def query_ins_chat(x, curs=cursor):
try: # Запрос добавления чата
curs.execute(
f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
curs.commit()
except Exception as e:
print("Ошибка:", e)
def query_sel(x, curs = cursor):
def query_sel(x, curs=cursor):
try:
# Запрос вывода из БД
curs.execute("SELECT * FROM chats")
@@ -41,12 +43,12 @@ def query_sel(x, curs = cursor):
except Exception as e:
print("Ошибка:", e)
def query_change(x):
# Написать выдачу резов по ролям
pass
def close(cur = cursor, conn = connection):
def close(cur=cursor, conn=connection):
cursor.close()
connection.close()