@@ -188,7 +188,7 @@ from google.cloud.sql.connector import Connector, IPTypes
188188
189189# Note: all parameters below are optional
190190connector = Connector(
191- ip_type = IPTypes. PUBLIC ,
191+ ip_type = " public " , # can also be "private" or "psc"
192192 enable_iam_auth = False ,
193193 timeout = 30 ,
194194 credentials = custom_creds # google.auth.credentials.Credentials
@@ -261,18 +261,16 @@ using both public and private IP addresses, as well as
261261with, set the ` ip_type ` keyword argument when initializing a ` Connector() ` or when
262262calling ` connector.connect() ` .
263263
264- Possible values for ` ip_type ` are ` IPTypes.PUBLIC ` (default value),
265- ` IPTypes.PRIVATE ` , and ` IPTypes.PSC ` .
264+ Possible values for ` ip_type ` are ` "public" ` (default value),
265+ ` "private" ` , and ` "psc" ` .
266266
267267Example:
268268
269269``` python
270- from google.cloud.sql.connector import IPTypes
271-
272270conn = connector.connect(
273271 " project:region:instance" ,
274272 " pymysql" ,
275- ip_type = IPTypes. PRIVATE # use private IP
273+ ip_type = " private " # use private IP
276274... insert other kwargs ...
277275)
278276```
@@ -333,7 +331,7 @@ conn = connector.connect(
333331 db = " my-db-name" ,
334332 active_directory_auth = True ,
335333 server_name = " private.[instance].[location].[project].cloudsql.[domain]" ,
336- ip_type = IPTypes. PRIVATE
334+ ip_type = " private "
337335)
338336```
339337
@@ -358,7 +356,7 @@ your web application through the following:
358356``` python
359357from flask import Flask
360358from flask_sqlalchemy import SQLAlchemy
361- from google.cloud.sql.connector import Connector, IPTypes
359+ from google.cloud.sql.connector import Connector
362360
363361
364362# initialize Python Connector object
@@ -372,7 +370,7 @@ def getconn():
372370 user = " my-user" ,
373371 password = " my-password" ,
374372 db = " my-database" ,
375- ip_type = IPTypes. PUBLIC # IPTypes.PRIVATE for private IP
373+ ip_type = " public " # "private" for private IP
376374 )
377375 return conn
378376
@@ -407,7 +405,7 @@ from sqlalchemy import create_engine
407405from sqlalchemy.engine import Engine
408406from sqlalchemy.ext.declarative import declarative_base
409407from sqlalchemy.orm import sessionmaker
410- from google.cloud.sql.connector import Connector, IPTypes
408+ from google.cloud.sql.connector import Connector
411409
412410# helper function to return SQLAlchemy connection pool
413411def init_connection_pool (connector : Connector) -> Engine:
@@ -419,7 +417,7 @@ def init_connection_pool(connector: Connector) -> Engine:
419417 user = " my-user" ,
420418 password = " my-password" ,
421419 db = " my-database" ,
422- ip_type = IPTypes. PUBLIC # IPTypes.PRIVATE for private IP
420+ ip_type = " public " # "private" for private IP
423421 )
424422 return conn
425423
0 commit comments