@@ -32,7 +32,7 @@ async def create_sqlalchemy_engine(
3232 user : str ,
3333 password : str ,
3434 db : str ,
35- ip_type : str ,
35+ ip_type : str = "public" ,
3636 refresh_strategy : str = "background" ,
3737 resolver : Union [type [DefaultResolver ], type [DnsResolver ]] = DefaultResolver ,
3838) -> tuple [sqlalchemy .ext .asyncio .engine .AsyncEngine , Connector ]:
@@ -65,7 +65,7 @@ async def create_sqlalchemy_engine(
6565 db (str):
6666 The name of the database, e.g., mydb
6767 ip_type (str):
68- The IP type of the Cloud SQL instance.
68+ The IP type of the Cloud SQL instance. Can be one of "public", "private", or "psc".
6969 refresh_strategy (Optional[str]):
7070 Refresh strategy for the Cloud SQL Connector. Can be one of "lazy"
7171 or "background". For serverless environments use "lazy" to avoid
@@ -90,7 +90,7 @@ async def create_sqlalchemy_engine(
9090 user = user ,
9191 password = password ,
9292 db = db ,
93- ip_type = ip_type ,
93+ ip_type = ip_type , # can be "public", "private" or "psc"
9494 ),
9595 execution_options = {"isolation_level" : "AUTOCOMMIT" },
9696 )
@@ -102,7 +102,7 @@ async def create_asyncpg_pool(
102102 user : str ,
103103 password : str ,
104104 db : str ,
105- ip_type : str ,
105+ ip_type : str = "public" ,
106106 refresh_strategy : str = "background" ,
107107) -> tuple [asyncpg .Pool , Connector ]:
108108 """Creates a native asyncpg connection pool for a Cloud SQL instance and
@@ -133,7 +133,7 @@ async def create_asyncpg_pool(
133133 db (str):
134134 The name of the database, e.g., mydb
135135 ip_type (str):
136- The IP type of the Cloud SQL instance.
136+ The IP type of the Cloud SQL instance. Can be one of "public", "private", or "psc".
137137 refresh_strategy (Optional[str]):
138138 Refresh strategy for the Cloud SQL Connector. Can be one of "lazy"
139139 or "background". For serverless environments use "lazy" to avoid
@@ -151,7 +151,7 @@ async def getconn(
151151 user = user ,
152152 password = password ,
153153 db = db ,
154- ip_type = ip_type ,
154+ ip_type = ip_type , # can be "public", "private" or "psc"
155155 ** kwargs ,
156156 )
157157 return conn
@@ -167,7 +167,7 @@ async def test_sqlalchemy_connection_with_asyncpg() -> None:
167167 user = os .environ ["POSTGRES_USER" ]
168168 password = os .environ ["POSTGRES_PASS" ]
169169 db = os .environ ["POSTGRES_DB" ]
170- ip_type = os .environ .get ("IP_TYPE" , "public" ) # can be "public", "private" or "psc"
170+ ip_type = os .environ .get ("IP_TYPE" , "public" )
171171
172172 pool , connector = await create_sqlalchemy_engine (
173173 inst_conn_name , user , password , db , ip_type
@@ -186,7 +186,7 @@ async def test_lazy_sqlalchemy_connection_with_asyncpg() -> None:
186186 user = os .environ ["POSTGRES_USER" ]
187187 password = os .environ ["POSTGRES_PASS" ]
188188 db = os .environ ["POSTGRES_DB" ]
189- ip_type = os .environ .get ("IP_TYPE" , "public" ) # can be "public", "private" or "psc"
189+ ip_type = os .environ .get ("IP_TYPE" , "public" )
190190
191191 pool , connector = await create_sqlalchemy_engine (
192192 inst_conn_name , user , password , db , ip_type , "lazy"
@@ -205,7 +205,7 @@ async def test_custom_SAN_with_dns_sqlalchemy_connection_with_asyncpg() -> None:
205205 user = os .environ ["POSTGRES_USER" ]
206206 password = os .environ ["POSTGRES_CUSTOMER_CAS_PASS" ]
207207 db = os .environ ["POSTGRES_DB" ]
208- ip_type = os .environ .get ("IP_TYPE" , "public" ) # can be "public", "private" or "psc"
208+ ip_type = os .environ .get ("IP_TYPE" , "public" )
209209
210210 pool , connector = await create_sqlalchemy_engine (
211211 inst_conn_name , user , password , db , ip_type , resolver = DnsResolver
@@ -224,7 +224,7 @@ async def test_connection_with_asyncpg() -> None:
224224 user = os .environ ["POSTGRES_USER" ]
225225 password = os .environ ["POSTGRES_PASS" ]
226226 db = os .environ ["POSTGRES_DB" ]
227- ip_type = os .environ .get ("IP_TYPE" , "public" ) # can be "public", "private" or "psc"
227+ ip_type = os .environ .get ("IP_TYPE" , "public" )
228228
229229 pool , connector = await create_asyncpg_pool (
230230 inst_conn_name , user , password , db , ip_type
@@ -243,7 +243,7 @@ async def test_lazy_connection_with_asyncpg() -> None:
243243 user = os .environ ["POSTGRES_USER" ]
244244 password = os .environ ["POSTGRES_PASS" ]
245245 db = os .environ ["POSTGRES_DB" ]
246- ip_type = os .environ .get ("IP_TYPE" , "public" ) # can be "public", "private" or "psc"
246+ ip_type = os .environ .get ("IP_TYPE" , "public" )
247247
248248 pool , connector = await create_asyncpg_pool (
249249 inst_conn_name , user , password , db , ip_type , "lazy"
0 commit comments