mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-19 18:45:15 +02:00
chore: prepare cloud merge point with docker and firebase configs in movexe fork Boris account? No, current user.
This commit is contained in:
parent
b38a297349
commit
4a6b335ce3
14 changed files with 263 additions and 2 deletions
25
surfsense_backend/test_db_sa.py
Normal file
25
surfsense_backend/test_db_sa.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import asyncio
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy import text
|
||||
|
||||
async def main():
|
||||
load_dotenv()
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
db_url = db_url.replace("postgresql+asyncpg", "postgresql+psycopg")
|
||||
if "ssl=require" in db_url:
|
||||
db_url = db_url.replace("ssl=require", "sslmode=require")
|
||||
engine = create_async_engine(db_url)
|
||||
print(f"Connecting to {db_url} using SQLAlchemy async psycopg")
|
||||
try:
|
||||
async with engine.begin() as conn:
|
||||
res = await conn.execute(text("SELECT 1"))
|
||||
print(f"SUCCESS! Result: {res.scalar()}")
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue