summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jwebmail/read_mails.py20
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()