1
0

merge aigpt

This commit is contained in:
2025-06-02 18:24:43 +09:00
parent 6dbe630b9d
commit 6cd8014f80
16 changed files with 850 additions and 368 deletions

View File

@ -1,5 +1,6 @@
"""Initialize database with master data"""
import asyncio
from sqlalchemy import text, select, func
from sqlalchemy.ext.asyncio import AsyncSession
from app.db.base import engine, Base, async_session
from app.db.models import CardMaster
@ -35,10 +36,14 @@ async def init_db():
print("Inserting master data...")
async with async_session() as session:
# Check if master data already exists
existing = await session.execute(
"SELECT COUNT(*) FROM card_master"
)
count = existing.scalar()
try:
result = await session.execute(
select(func.count()).select_from(CardMaster)
)
count = result.scalar()
except Exception:
# Table might not exist yet
count = 0
if count == 0:
# Insert card master data