mirror of
https://github.com/IgorL123/mafia_api.git
synced 2026-09-23 23:20:19 +00:00
add insUser + insChat
This commit is contained in:
@@ -11,29 +11,29 @@ db_params = {
|
|||||||
connection = psycopg2.connect(**db_params)
|
connection = psycopg2.connect(**db_params)
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
def query_ins_user(str x):
|
def query_ins_user(str x, curs = cursor):
|
||||||
try:
|
try:
|
||||||
# Запрос добавления пользователя
|
# Запрос добавления пользователя
|
||||||
cursor.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)""")
|
||||||
cursor.commit()
|
curs.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Ошибка:", e)
|
print("Ошибка:", e)
|
||||||
|
|
||||||
|
|
||||||
def query_ins_chat(str x):
|
def query_ins_chat(str x, curs = cursor):
|
||||||
try: # Запрос добавления чата
|
try: # Запрос добавления чата
|
||||||
cursor.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
|
curs.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
|
||||||
cursor.commit()
|
curs.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Ошибка:", e)
|
print("Ошибка:", e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def query_sel(str x):
|
def query_sel(str x, curs = cursor):
|
||||||
try:
|
try:
|
||||||
# Запрос вывода из БД
|
# Запрос вывода из БД
|
||||||
cursor.execute("SELECT * FROM chats")
|
curs.execute("SELECT * FROM chats")
|
||||||
rows = cursor.fetchall()
|
rows = curs.fetchall()
|
||||||
|
|
||||||
# for row in rows:
|
# for row in rows:
|
||||||
# print(row)
|
# print(row)
|
||||||
@@ -41,6 +41,11 @@ def query_sel(str x):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Ошибка:", e)
|
print("Ошибка:", e)
|
||||||
|
|
||||||
|
def query_change(str x):
|
||||||
|
# Написать выдачу резов по ролям
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def close(cur = cursor, conn = connection):
|
def close(cur = cursor, conn = connection):
|
||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user