mirror of
https://github.com/IgorL123/mafia_api.git
synced 2026-09-24 07:30:15 +00:00
update 0.2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import Flask
|
||||
from flask import Flask, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -7,7 +7,7 @@ app = Flask(__name__)
|
||||
def hello_world(): # put application's code here
|
||||
return 'Hello World!'
|
||||
|
||||
@app.route('/create_game')
|
||||
@app.route('/create_game', method = ["POST"])
|
||||
def create(str truechatid):
|
||||
|
||||
|
||||
|
||||
@@ -8,21 +8,40 @@ db_params = {
|
||||
'password': '4oumQk'
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
def query_sel(str x):
|
||||
try:
|
||||
# Запрос вывода из БД
|
||||
cursor.execute("SELECT * FROM chats")
|
||||
rows = cursor.fetchall()
|
||||
|
||||
for row in rows:
|
||||
print(row)
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
# for row in rows:
|
||||
# print(row)
|
||||
|
||||
except Exception as e:
|
||||
print("Ошибка:", e)
|
||||
|
||||
def close(cur = cursor, conn = connection):
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user