Initial commit: memo app with FastAPI, SQLite, APScheduler, Discord notifications

This commit is contained in:
2026-04-30 14:03:11 +02:00
commit 748ee8ae75
11 changed files with 727 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import sqlite3
import os
from contextlib import contextmanager
DB_PATH = os.environ.get("DB_PATH", "/data/memo.db")
SCHEMA = """
CREATE TABLE IF NOT EXISTS memos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
description TEXT DEFAULT '',
reminder_time TEXT NOT NULL DEFAULT '09:00',
created_at TEXT DEFAULT (datetime('now', 'localtime')),
done_at TEXT,
is_done INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS settings (
key TEXT PRIMARY KEY,
value TEXT NOT NULL DEFAULT ''
);
INSERT OR IGNORE INTO settings (key, value) VALUES ('discord_webhook', '');
INSERT OR IGNORE INTO settings (key, value) VALUES ('timezone', 'Europe/Paris');
"""
@contextmanager
def get_db():
conn = sqlite3.connect(DB_PATH)
conn.row_factory = sqlite3.Row
try:
yield conn
conn.commit()
finally:
conn.close()
def init_db():
with get_db() as conn:
conn.executescript(SCHEMA)