-
-
Save jackwotherspoon/8a9af3ac1e60e493d32364b3931c6feb to your computer and use it in GitHub Desktop.
AlloyDB Private IP Connection test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import os | |
import asyncpg | |
async def main() -> None: | |
"""Basic test to get time from database using native asyncpg connection.""" | |
async with asyncpg.create_pool( | |
user="postgres", | |
password="my-password", | |
host="10.59.16.2", # your AlloyDB instance IP address | |
port=5432, | |
database="postgres", # your database name | |
ssl="require", | |
) as pool: | |
# acquire connection from native asyncpg connection pool | |
async with pool.acquire() as conn: | |
time = await conn.fetchrow("SELECT NOW()") | |
print("Current time is ", time[0]) | |
# run main | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment