I set this up on my local machine with CloudSQL and it works great, but when I pushed to AppEngine with gcloud app deploy and go to the resulting webpage, I get:
(pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")
Any idea what's up?
Hi, a few questions:
On Fri, Sep 30, 2016 at 9:58 AM, Jon Wayne Parrott <[email protected]
wrote:
Hi, a few questions:
- Are you using Cloud SQL 2nd Generation?
- Did you uncomment this line
https://github.com/GoogleCloudPlatform/getting-started-python/blob/master/2-structured-data/app.yaml#L33
in app.yaml?- Can you double check these settings
https://github.com/GoogleCloudPlatform/getting-started-python/blob/master/2-structured-data/config.py#L40
?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/GoogleCloudPlatform/getting-started-python/issues/92#issuecomment-250797011,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFmurWfoaVJiJjrxtn-69ZeXj7WLZvxsks5qvT--gaJpZM4KKvWx
.
Thanks, I'll try to reproduce.
Hrm, I wasn't able to reproduce. Can you paste in your config.py with your project id and password elided?
config: http://pastebin.com/YVaxKeUg
app.yaml: http://pastebin.com/t1MjCD6e
On Fri, Sep 30, 2016 at 11:14 AM, Jon Wayne Parrott <
[email protected]> wrote:
Hrm, I wasn't able to reproduce. Can you paste in your config.py with your
project id and password elided?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/GoogleCloudPlatform/getting-started-python/issues/92#issuecomment-250814659,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFmurUNZ33QIM4yZBmnGHLYko7f58orqks5qvVGVgaJpZM4KKvWx
.
@beshaya Hmmm, all of your configuration looks correct.
Can you check and make sure the Cloud SQL Admin API is enabled in the cloud console?
I have the same problem than @beshaya!
works fine locally but when deply to GEA, Can't connect to MySQL server on 'localhost' raices.
(Cloud SQL is enabled admin API)
This may just be an issue with the environment variable. I'm investigating.
Hmm - the environment variable seems correct. I'm not sure why this is occurring and I can't seem to reproduce. Could you try printing the SQLALCHEMY_DATABASE_URI at the end of config.py and seeing what it's pointing to in your logs?
Hi John,
I've given up on CloudSQL and switched to Firebase. It's a better fit for
my application.
One thought - does it matter whether I'm using a standard or flexible app
engine instance?
On Mon, Oct 10, 2016 at 10:06 AM, Jon Wayne Parrott <
[email protected]> wrote:
Hmm - the environment variable seems correct. I'm not sure why this is
occurring and I can't seem to reproduce. Could you try printing the
SQLALCHEMY_DATABASE_URI at the end of config.py and seeing what it's
pointing to in your logs?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/GoogleCloudPlatform/getting-started-python/issues/92#issuecomment-252680591,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFmurZSe4weoaS7s4RUmkODlkY6nF_Vzks5qynCDgaJpZM4KKvWx
.
@beshaya this application is intended for flexible. You can use Cloud SQL from both standard and flexible, but the configuration is slightly different between the two.
For Firebase, it shouldn't matter.
Did anyone ever find a solution to this problem? I am facing it as well.
I have setup a MySQL Second Generation instance.
It is working when run locally.
Have the following flag in my
beta_settings:
cloud_sql_instances: "datascrub-152522:us-central1:datascrub"
I described a potential solution (enabling Cloud SQL Admin API) here: https://github.com/GoogleCloudPlatform/getting-started-python/issues/129#issuecomment-332803546
@larsblumberg 's solution worked for me, enabling the administration api.
Can we also add this as a step to the tutorial here? https://cloud.google.com/python/getting-started/tutorial-app
Ideal would be to pass this solution in the error text, as app logs aren't visible by default from command line. Not sure how hard that is.
@bwindsor22 the "Enable the APIs" button already ensures that the SQL Admin API is enabled.
@jonparott, ah, I see
this application is intended for flexible. You can use Cloud SQL from both standard and flexible, but the configuration is slightly different between the two.
@theacodes would you please elaborate on how configurations between the two differ?
context (maybe this part should be a separate question or stackoverflow post, so you can ignore if it's not relevant): I'm trying to work around this problem, none of the solutions here or in the linked issues have worked for me so far. I created a project for the Standard Environment following https://cloud.google.com/appengine/docs/standard/python/cloud-sql/using-cloud-sql-mysql#setting-up, but would like to use pymysql instead of MySQLdb because it has been a pain trying to install the latter on my system (macOS, using virtualenv). I would like to know if it is possible to use pymysql in a Standard Environment, and if so, how to set up the configs?
@andrewsg should be able to help
I'm not sure if it's true at all but so far from my experience and that of OP in this SO post it seems PyMySQL is not supported in the standard environment. @andrewsg can confirm? Or know an alternative? Still facing headaches installing MySQLdb on mac+virtualenv
I can confirm that pymysql is not supported in the python27 runtime. However, for most use cases, it's possible to use pymysql locally and mysqldb in production by using a try: / except ImportError: to import one or the other conditionally. As they share the same interface, you can use import as to make the two different libraries share the same name for ease of use in your code.
Django is a special case since the database driver is configured by the framework and not invoked directly. If you are using Django, you can put this at the top of your settings.py file:
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
Good to know, @andrewsg. I finally managed to install MySQLdb locally after fighting for a few days with virtualenv. Issue was related to the DistutilsOptionError discussed further in this Stack Overflow post
I have the same issue, following the steps here. The app runs fine locally, but gives the same error as mentioned when deployed. Are there any solutions?