Skip to content

Instantly share code, notes, and snippets.

View jackwotherspoon's full-sized avatar

Jack Wotherspoon jackwotherspoon

View GitHub Profile
@jackwotherspoon
jackwotherspoon / connector_private_ip.py
Last active May 26, 2023 13:46
Cloud SQL Connector Private IP
from google.cloud.sql.connector import Connector, IPTypes
import sqlalchemy
def init_connection_pool(connector: Connector):
def getconn():
connection = connector.connect(
"PROJECT:REGION:INSTANCE_NAME",
"pg8000",
user="my-user",
password="my-password",
from google.cloud.sql.connector import Connector
import sqlalchemy
# wrap engine creation so arguments are dynamically passed
def init_connection_engine(connector: Connector, instance_connection_name: str, user: str, password: str):
def getconn():
connection = connector.connect(
instance_connection_name,
"pg8000",
user=user,