From 1d0edda3f461af086e0287b64dbebe041d04a198 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Mon, 9 Dec 2024 13:08:28 +0100 Subject: better formatting of long sql queries --- src/jwebmail/read_mails.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/jwebmail/read_mails.py b/src/jwebmail/read_mails.py index 4e2b0c7..5aed8d2 100644 --- a/src/jwebmail/read_mails.py +++ b/src/jwebmail/read_mails.py @@ -87,14 +87,23 @@ class SqliteTimeoutSession: self.conn = sqlite3.connect(database, isolation_level="IMMEDIATE") cur = self.conn.cursor() cur.execute( - "CREATE TABLE IF NOT EXISTS session (user text PRIMARY KEY, password text, timeout integer NOT NULL) STRICT" + """ + CREATE TABLE IF NOT EXISTS session ( + user text PRIMARY KEY, + password text, + timeout integer NOT NULL + ) STRICT + """ ) cur.execute("CREATE INDEX IF NOT EXISTS timeout_idx ON session (timeout)") def set(self, key, value): with closing(self.conn.cursor()) as cur: cur.execute( - "INSERT OR REPLACE INTO session VALUES (?, ?, unixepoch('now', format('%d seconds', ?)))", + """ + INSERT OR REPLACE INTO session + VALUES (?, ?, unixepoch('now', format('%d seconds', ?))) + """, [key, value, self.timeout], ) self.conn.commit() @@ -103,7 +112,12 @@ class SqliteTimeoutSession: with closing(self.conn.cursor()) as cur: cur.execute("DELETE FROM session WHERE timeout < unixepoch()") cur.execute( - "UPDATE session SET timeout = unixepoch('now', format('%d seconds', ?)) WHERE user = ? RETURNING password", + """ + UPDATE session + SET timeout = unixepoch('now', format('%d seconds', ?)) + WHERE user = ? + RETURNING password + """, [self.timeout, key], ) row = cur.fetchone() -- cgit v1.2.3