From 7f0b57c47ce75862dc31cb2a0b126818857d8c93 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Fri, 6 Mar 2026 19:20:52 +0800 Subject: [PATCH] feat: Initialize data infrastructure by adding historical weather data, various data storage files, a database manager, logging, and updating Docker Compose configuration. --- data/polyweather.db | Bin 0 -> 8192 bytes docker-compose.yml | 2 -- src/database/db_manager.py | 18 ++++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 data/polyweather.db diff --git a/data/polyweather.db b/data/polyweather.db new file mode 100644 index 0000000000000000000000000000000000000000..ea5e1ca510688fdd0cd419ef423f38792092b084 GIT binary patch literal 8192 zcmeI#&r8EF6bJBR2!b&1w(C18$Po1A#coC!c0cSgaHo)MaTM0IG%4!cga4iXlIdhc zu&@c9~p#u)db;m0=0^}%-G@8x<|aMr%0 zrqANd59Tif1Rwwb2tWV=5P$##AOHaf{Efg{n;*7XE&hJx^lW7cYjV4p8r?_)QjiQf zp`gtpIys`6aAswexlUBPpx!`=I}y<+>h*(YO7~)VR$EkVxYmgwDIR5gN^I4$nW-!{ zNn9k<84g1c4CqGO29r?Id3{w`VqUU1e str: + raw = (db_path or os.getenv("POLYWEATHER_DB_PATH") or "").strip() + if not raw: + project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + return os.path.join(project_root, "data", "polyweather.db") + return raw + def _get_connection(self): return sqlite3.connect(self.db_path) def _init_db(self): """Create tables if they don't exist.""" # Ensure directory exists - os.makedirs(os.path.dirname(self.db_path), exist_ok=True) + db_dir = os.path.dirname(self.db_path) + if db_dir: + os.makedirs(db_dir, exist_ok=True) with self._get_connection() as conn: conn.execute(""" CREATE TABLE IF NOT EXISTS users ( @@ -32,7 +42,7 @@ class DBManager: ) """) conn.commit() - logger.info("Database initialized successfully.") + logger.info(f"Database initialized successfully path={self.db_path}") def get_user(self, telegram_id: int) -> Optional[Dict[str, Any]]: with self._get_connection() as conn: