Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
import os
|
|
import asyncio
|
|
from sqlalchemy import text
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
from app.models.database import async_session_maker, engine
|
|
|
|
async def check():
|
|
async with async_session_maker() as session:
|
|
try:
|
|
print(f"DATABASE URL: {engine.url}")
|
|
# Check table existence and columns
|
|
print("Checking alerts table...")
|
|
res = await session.execute(text("DESCRIBE alerts"))
|
|
columns = res.fetchall()
|
|
for col in columns:
|
|
print(f"Column: {col}")
|
|
|
|
# Try a dry insertion
|
|
print("\nAttempting dry insertion...")
|
|
# Use columns found or assume standard ones
|
|
stmt = text("INSERT INTO alerts (category, title, level, message, source, created_at) VALUES ('test', 'Test', 'info', 'Test', 'script', NOW())")
|
|
res = await session.execute(stmt)
|
|
print(f"Insert success, rowcount: {res.rowcount}")
|
|
await session.commit()
|
|
print("Commit success")
|
|
|
|
except Exception as e:
|
|
print(f"\nERROR: {type(e).__name__}: {str(e)}")
|
|
if hasattr(e, 'orig'):
|
|
print(f"Original error: {e.orig}")
|
|
|
|
if __name__ == "__main__":
|
|
loop = asyncio.get_event_loop()
|
|
loop.run_until_complete(check())
|
|
# Don't close explicitly, or wait a bit
|