import asyncio from sqlalchemy import create_engine, text from chainlit.data.sql_alchemy import SQLAlchemyDataLayer DATABASE_URL = "postgresql+asyncpg://ai_user:secure_password_here@postgres:5432/ai_station" async def init_database(): """Inizializza le tabelle per Chainlit""" print("🔧 Inizializzazione database...") try: # Crea data layer data_layer = SQLAlchemyDataLayer(conninfo=DATABASE_URL) # Forza creazione tabelle if hasattr(data_layer, '_create_database'): await data_layer._create_database() print("✅ Database inizializzato con successo") else: print("âš ī¸ Metodo _create_database non disponibile") print("â„šī¸ Le tabelle verranno create automaticamente al primo utilizzo") except Exception as e: print(f"❌ Errore: {e}") if __name__ == "__main__": asyncio.run(init_database())