From caae3944492b43e470babc500b913e285bf1ea88 Mon Sep 17 00:00:00 2001 From: Jari Wiik Date: Thu, 16 Nov 2023 22:46:25 +0200 Subject: Fix lock-up situation when database gets zapped while session is still on --- db_actions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'db_actions.py') diff --git a/db_actions.py b/db_actions.py index 26f69df..fca9ab0 100644 --- a/db_actions.py +++ b/db_actions.py @@ -21,7 +21,8 @@ def user_get_nick(id): sql = "SELECT nick \ FROM users \ WHERE id=(:id);" - return db.session.execute(text(sql), { "id":id }).fetchone()[0] + result = db.session.execute(text(sql), { "id":id }).fetchone() + return result[0] if result else result def user_exists(nick): sql = "SELECT COUNT(id) \ -- cgit v1.2.3