mirror of
https://github.com/skoelle/calender_sync.git
synced 2026-09-17 18:20:24 +00:00
feat: REST API + Web-Frontend für Kalenderübersicht
- FastAPI Backend mit /api/events, /api/events/{id}, /api/health Endpoints
- Optionale Suche nach Event-Titel (Query Parameter ?search=...)
- Jinja2 Web-Frontend auf / mit Suchfeld
- Shared DB Connection Module (api/database.py)
- Docker Compose: calendar-api Service hinzugefügt
- Sync.py refactored: nutzt shared database.py
This commit is contained in:
@@ -18,6 +18,8 @@ import recurring_ical_events
|
||||
import mysql.connector
|
||||
from mysql.connector import Error as MySQLError
|
||||
|
||||
from api.database import get_connection
|
||||
|
||||
logging.basicConfig(
|
||||
level=os.environ.get("LOG_LEVEL", "INFO"),
|
||||
format="%(asctime)s [%(levelname)s] %(message)s",
|
||||
@@ -78,17 +80,6 @@ def bootstrap_database():
|
||||
root_conn.close()
|
||||
|
||||
|
||||
def get_connection():
|
||||
return mysql.connector.connect(
|
||||
host=DB_HOST,
|
||||
port=DB_PORT,
|
||||
user=DB_USER,
|
||||
password=DB_PASSWORD,
|
||||
database=DB_NAME,
|
||||
autocommit=False,
|
||||
)
|
||||
|
||||
|
||||
def ensure_schema(conn):
|
||||
cur = conn.cursor()
|
||||
cur.execute("""
|
||||
@@ -228,7 +219,7 @@ def run_sync_once():
|
||||
occurrences = expand_events(ics_bytes, window_start, window_end)
|
||||
log.info("ICS geladen, %d Instanzen im Fenster gefunden", len(occurrences))
|
||||
|
||||
conn = get_connection()
|
||||
conn = get_connection(autocommit=False)
|
||||
try:
|
||||
ensure_schema(conn)
|
||||
cur = conn.cursor()
|
||||
|
||||
Reference in New Issue
Block a user