mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-09 15:52:40 +02:00
22 lines
542 B
Python
22 lines
542 B
Python
|
|
import asyncio
|
||
|
|
import asyncpg
|
||
|
|
import os
|
||
|
|
from dotenv import load_dotenv
|
||
|
|
|
||
|
|
async def main():
|
||
|
|
load_dotenv()
|
||
|
|
db_url = os.getenv("DATABASE_URL")
|
||
|
|
if db_url.startswith("postgresql+asyncpg"):
|
||
|
|
db_url = db_url.replace("postgresql+asyncpg", "postgresql")
|
||
|
|
|
||
|
|
print(f"Connecting to {db_url}")
|
||
|
|
try:
|
||
|
|
conn = await asyncpg.connect(db_url)
|
||
|
|
print("SUCCESS: Connected to Neon DB!")
|
||
|
|
await conn.close()
|
||
|
|
except Exception as e:
|
||
|
|
print(f"ERROR: {e}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
asyncio.run(main())
|