diff --git a/db.py b/db.py index 7e500e4..bed411e 100644 --- a/db.py +++ b/db.py @@ -11,29 +11,29 @@ db_params = { connection = psycopg2.connect(**db_params) cursor = connection.cursor() -def query_ins_user(str x): +def query_ins_user(str x, curs = cursor): try: # Запрос добавления пользователя - cursor.execute(f"""INSERT into public.Users(TrueUserID, role, isAlive) values ({x}, 0)""") - cursor.commit() + 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(str x): +def query_ins_chat(str x, curs = cursor): try: # Запрос добавления чата - cursor.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""") - cursor.commit() + curs.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""") + curs.commit() except Exception as e: print("Ошибка:", e) -def query_sel(str x): +def query_sel(str x, curs = cursor): try: # Запрос вывода из БД - cursor.execute("SELECT * FROM chats") - rows = cursor.fetchall() + curs.execute("SELECT * FROM chats") + rows = curs.fetchall() # for row in rows: # print(row) @@ -41,6 +41,11 @@ def query_sel(str x): except Exception as e: print("Ошибка:", e) +def query_change(str x): + # Написать выдачу резов по ролям + + + def close(cur = cursor, conn = connection): cursor.close() connection.close()