mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 21:12:55 +00:00
30 lines
602 B
Python
Executable File
30 lines
602 B
Python
Executable File
#! /usr/bin/env python3
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
import asyncpg
|
|
|
|
|
|
async def run(**kwargs) -> asyncpg.Record:
|
|
conn = await asyncpg.connect(
|
|
**kwargs,
|
|
statement_cache_size=0, # Prepared statements doesn't work pgbouncer
|
|
)
|
|
rv = await conn.fetchrow("SELECT 1")
|
|
await conn.close()
|
|
|
|
return rv
|
|
|
|
|
|
if __name__ == "__main__":
|
|
kwargs = {
|
|
k.lstrip("NEON_").lower(): v
|
|
for k in ("NEON_HOST", "NEON_DATABASE", "NEON_USER", "NEON_PASSWORD")
|
|
if (v := os.environ.get(k, None)) is not None
|
|
}
|
|
|
|
row = asyncio.run(run(**kwargs))
|
|
|
|
print(row[0])
|