update 0.2

This commit is contained in:
ada-dmitry
2023-08-22 15:02:37 +03:00
parent 6b33df6081
commit 3e6834ed87
2 changed files with 33 additions and 14 deletions
+29 -10
View File
@@ -8,21 +8,40 @@ db_params = {
'password': '4oumQk'
}
connection = psycopg2.connect(**db_params)
cursor = connection.cursor()
try:
connection = psycopg2.connect(**db_params)
cursor = connection.cursor()
def query_ins_user(str x):
try:
# Запрос добавления пользователя
cursor.execute(f"""INSERT into public.Users(TrueUserID, role, isAlive) values ({x}, 0)""")
cursor.commit()
except Exception as e:
print("Ошибка:", e)
# Ваш код выполнения запросов
def query_ins_chat(str x):
try: # Запрос добавления чата
cursor.execute(f"""INSERT into public.Chats(TrueChatID, StateID) values ({x}, 0)""")
cursor.commit()
except Exception as e:
print("Ошибка:", e)
cursor.execute("SELECT * FROM chats")
rows = cursor.fetchall()
for row in rows:
print(row)
def query_sel(str x):
try:
# Запрос вывода из БД
cursor.execute("SELECT * FROM chats")
rows = cursor.fetchall()
# for row in rows:
# print(row)
except Exception as e:
print("Ошибка:", e)
def close(cur = cursor, conn = connection):
cursor.close()
connection.close()
except Exception as e:
print("Ошибка:", e)