Started with db development
This commit is contained in:
@@ -18,20 +18,38 @@ from .simplified_access import (
|
||||
)
|
||||
|
||||
# DB and config
|
||||
from .db import Customer as DBCustomer, Reservation as DBReservation, HashedCustomer, SessionLocal, init_db
|
||||
from .db import Customer as DBCustomer, Reservation as DBReservation, HashedCustomer, get_session_local, init_db
|
||||
from .config_loader import load_config
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def main():
|
||||
import json
|
||||
import os
|
||||
|
||||
print("🚀 Starting AlpineBits XML generation script...")
|
||||
# Load config (yaml, annotatedyaml)
|
||||
config = load_config()
|
||||
|
||||
# print config for debugging
|
||||
print("Loaded configuration:")
|
||||
print(json.dumps(config, indent=2))
|
||||
|
||||
# Ensure SQLite DB file exists if using SQLite
|
||||
db_url = config.get('database', {}).get('url', '')
|
||||
if db_url.startswith('sqlite:///'):
|
||||
db_path = db_url.replace('sqlite:///', '')
|
||||
db_path = os.path.abspath(db_path)
|
||||
db_dir = os.path.dirname(db_path)
|
||||
if not os.path.exists(db_dir):
|
||||
os.makedirs(db_dir, exist_ok=True)
|
||||
# The DB file will be created by SQLAlchemy if it doesn't exist, but ensure directory exists
|
||||
|
||||
# Init DB
|
||||
init_db()
|
||||
init_db(config)
|
||||
|
||||
print("📦 Database initialized/ready.")
|
||||
SessionLocal = get_session_local(config)
|
||||
db = SessionLocal()
|
||||
|
||||
# Load data from JSON file
|
||||
|
||||
Reference in New Issue
Block a user