Spaces:
Paused
Paused
| import os | |
| import sys | |
| from sqlalchemy import create_engine, text | |
| # Add path to find config | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | |
| from src.core.config import Config | |
| def create_table(): | |
| print("π§ Connecting to Cloud DB...") | |
| config = Config() | |
| try: | |
| engine = create_engine(config.DB_URL) | |
| with engine.connect() as conn: | |
| print("π¨ Creating 'feedback_logs' table...") | |
| conn.execute(text(""" | |
| CREATE TABLE IF NOT EXISTS feedback_logs ( | |
| id SERIAL PRIMARY KEY, | |
| user_id INTEGER, | |
| prompt TEXT, | |
| ai_response TEXT, | |
| user_correction TEXT, | |
| feedback_type TEXT, | |
| created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
| ); | |
| """)) | |
| conn.commit() | |
| print("β Success! Feedback table is ready in Neon.") | |
| except Exception as e: | |
| print(f"β DB Error: {e}") | |
| if __name__ == "__main__": | |
| create_table() | |