remove inquirer completely and fix saving app to db

This commit is contained in:
LeonOstrez
2023-07-28 14:38:13 +02:00
parent 32e988db24
commit 02dc329933
5 changed files with 55 additions and 36 deletions

View File

@@ -93,15 +93,20 @@ def save_app(user_id, app_id, app_type):
cursor.execute("INSERT INTO users (id, username, email, password) VALUES (%s, 'username', 'email', 'password')",
(str(user_id),))
# Now save the app
cursor.execute("INSERT INTO apps (user_id, app_id, app_type, status) VALUES (%s, %s, %s, 'started') RETURNING id",
(str(user_id), (str(app_id)), app_type))
# Now save or update the app
cursor.execute("""
INSERT INTO apps (user_id, app_id, app_type, status)
VALUES (%s, %s, %s, 'started')
ON CONFLICT (app_id) DO UPDATE SET
user_id = EXCLUDED.user_id, app_type = EXCLUDED.app_type, status = EXCLUDED.status
RETURNING id
""", (str(user_id), str(app_id), app_type))
conn.commit()
cursor.close()
conn.close()
logger.info('User saved')
logger.info('App saved')
return