Spaces:
Sleeping
Sleeping
Download api/src/db.js from deep-weather-sim/dws: direct link, hf CLI and curl.
- Browser
- Download file 885 Bytes
-
https://huggingface.co/spaces/deep-weather-sim/dws/resolve/main/api/src/db.js
- Command line
-
hf download hf://spaces/deep-weather-sim/dws/api/src/db.js
-
curl -L -o db.js https://huggingface.co/spaces/deep-weather-sim/dws/resolve/main/api/src/db.js
885 Bytes
| import Database from 'better-sqlite3'; | |
| import path from 'path'; | |
| import { fileURLToPath } from 'url'; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = path.dirname(__filename); | |
| // Connexion à la DB partagée avec le Bot Python | |
| const DB_PATH = '/data/aviator_db.db'; | |
| let db; | |
| try { | |
| db = new Database(DB_PATH, { readonly: true }); | |
| console.log("✅ [API] Connecté à SQLite (Read-only mode)"); | |
| } catch (err) { | |
| console.error("❌ [API] Erreur de connexion DB:", err.message); | |
| process.exit(1); | |
| } | |
| // Récupérer les X derniers rounds | |
| export function getLastRounds(limit = 100) { | |
| return db.prepare('SELECT * FROM rounds ORDER BY id DESC LIMIT ?').all(limit); | |
| } | |
| // Récupérer TOUTES les cotes pour les calculs globaux | |
| export function getAllCotes() { | |
| const rows = db.prepare('SELECT cote FROM rounds').all(); | |
| return rows.map(r => r.cote); | |
| } |