Files
app_faturas/testar_fatura.py

21 lines
599 B
Python
Raw Normal View History

import asyncio
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy import text
DATABASE_URL = "postgresql+asyncpg://fatura:102030@ic-postgresql-FtOY:5432/app_faturas"
engine = create_async_engine(DATABASE_URL, echo=True)
async def testar_conexao():
try:
async with engine.connect() as conn:
result = await conn.execute(text("SELECT 1"))
row = await result.fetchone()
print("Resultado:", row)
except Exception as e:
print("Erro ao conectar no banco:", e)
if __name__ == "__main__":
asyncio.run(testar_conexao())