Skip to content

Added samples for using Cloud SQL with App Engine Python 3.7 Standard - #1672

Merged
andrewsg merged 9 commits into
masterfrom
michaelawyu-patch-appengine-py37-cloudsql
Oct 11, 2018
Merged

Added samples for using Cloud SQL with App Engine Python 3.7 Standard#1672
andrewsg merged 9 commits into
masterfrom
michaelawyu-patch-appengine-py37-cloudsql

Conversation

@michaelawyu

Copy link
Copy Markdown
Contributor

Pending approval of the new doc page.

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 29, 2018
@michaelawyu

Copy link
Copy Markdown
ContributorAuthor

The linter only supports Python 2.7 :(

import os

from flask import Flask
import mysql.connector

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might be intentionally standardizing on pymysql as it has the largest usage share and is easiest for our users to install. Is there a particular reason to go with mysql connector?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pymysql does not have built-in support for connection pooling :(

cursor.execute('SELECT NOW() as now;')
result = cursor.fetchall()
current_time = result[0][0]
cursor.close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The adaptor doesn't support anything like "with" statements (context managers) here, do they?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the reference and it does not seem to have the __enter__ and __exit__ method.

result = cursor.fetchall()
current_time = result[0][0]
cursor.close()
# If the connection comes from a pool, close() will send the connection

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good comment here!

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebotgooglebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Oct 10, 2018
@michaelawyu

Copy link
Copy Markdown
ContributorAuthor

@andrewsg Package updated, PTAL. Not sure why the CLA bot is triggered :(

@michaelawyu

Copy link
Copy Markdown
ContributorAuthor

New year resolution: Make the Linter recognize F-string. Everyone should use F-string!

@andrewsg

Copy link
Copy Markdown
Member

CLA bot is due to lack of github tag in some commits for Chen, should be resolved going forward

@michaelawyumichaelawyu changed the title [DO NOT MERGE] Added samples for using Cloud SQL with App Engine Python 3.7 StandardAdded samples for using Cloud SQL with App Engine Python 3.7 StandardOct 11, 2018
@andrewsg
andrewsg merged commit e461e9a into masterOct 11, 2018
@michaelawyu
michaelawyu deleted the michaelawyu-patch-appengine-py37-cloudsql branch October 11, 2018 23:27
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: noThis human has *not* signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@michaelawyu@googlebot@andrewsg