add sqldb init

This commit is contained in:
2025-08-31 20:18:43 +03:00
parent 12734e0f19
commit a29b927d97
2 changed files with 18 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ except ImportError:
DB_TYPE = 'sqlite3'
BASE_DIR = Path(__file__).resolve().parent
SCHEMA_PATH = BASE_DIR / "schema.sql" if DB_TYPE != 'sqlite3' else BASE_DIR / "schema_sqlite.sql"
DATABASE_URL = os.getenv("DATABASE_URL")
SQLITE_PATH = BASE_DIR / "instance" / "dev.db"
@@ -18,6 +18,10 @@ SQLITE_PATH = BASE_DIR / "instance" / "dev.db"
def is_postgres():
return DATABASE_URL and DATABASE_URL.lower().startswith("postgres")
if is_postgres():
SCHEMA_PATH = BASE_DIR / "schema.sql"
else:
SCHEMA_PATH = BASE_DIR / "schema_sqlite.sql"
def get_connection():
if is_postgres():