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 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", |
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 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, |