Versão em produção - código extraído do container
This commit is contained in:
20
testar_fatura.py
Executable file
20
testar_fatura.py
Executable file
@@ -0,0 +1,20 @@
|
||||
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())
|
||||
|
||||
Reference in New Issue
Block a user