diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-12-09 13:08:28 +0100 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-12-09 13:08:28 +0100 |
commit | 1d0edda3f461af086e0287b64dbebe041d04a198 (patch) | |
tree | 29272a6f3730f049cf9af022d140871d4d0e7edd | |
parent | 7f9f1d40e806aaf2e0017c0c157b76fb284b049f (diff) |
better formatting of long sql queries
-rw-r--r-- | src/jwebmail/read_mails.py | 20 |
1 files 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() |