Skip to content

Commit

Permalink
chore: extend Public IP README example (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon committed Jan 29, 2024
1 parent 3ed3d37 commit 3f14bb2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,30 @@ Example:
```python
from google.cloud.alloydb.connector import Connector, IPTypes

conn = connector.connect(
import sqlalchemy

# initialize Connector object
connector = Connector()

# function to return the database connection
def getconn():
return connector.connect(
"projects/<YOUR_PROJECT>/locations/<YOUR_REGION>/clusters/<YOUR_CLUSTER>/instances/<YOUR_INSTANCE>",
"pg8000",
user="my-user",
password="my-password",
db="my-db-name",
ip_type=IPTypes.PUBLIC, # use public IP
)

# create connection pool
pool = sqlalchemy.create_engine(
"postgresql+pg8000://",
creator=getconn,
)

# use connection pool...
connector.close()
```

## Support policy
Expand Down

0 comments on commit 3f14bb2

Please sign in to comment.