Reputation: 51
Does anyone have a working example of a simple Google Cloud mySQL DB connection on the newly released (august 2018) Google App Engine Standard Python 3.7.
If so, can you share that? The documentation of Google for these new Second generation GEA Standard seems absent at this moment.
Upvotes: 2
Views: 167
Reputation: 51
Finally solved by my friend....
example code:
CLOUDSQL_CONNECTION_NAME = os.environ.get('CLOUDSQL_CONNECTION_NAME')
CLOUDSQL_USER = os.environ.get('CLOUDSQL_USER')
CLOUDSQL_PASSWORD = os.environ.get('CLOUDSQL_PASSWORD')
cloudsql_unix_socket = os.path.join('/çloudsql', CLOUDSQL_CONNECTION_NAME)
db_writer = mysql.connector.connect(
unix_socket=cloudsql_unix_socket,
database=CLOUDSQL_DBNAME,
user=CLOUDSQL_USER,
passwd=CLOUDSQL_PASSWORD
)
Upvotes: 1