1

I want to insert data into a CloudSQL MySQL database from a local Python application, is this possible, if so how?

I have tried running the examples at the bottom of https://cloud.google.com/appengine/docs/python/cloud-sql/#Python_complete_python_example

db = MySQLdb.connect(unix_socket='/cloudsql/PROJECT-ID:INSTANCE-NAME', user='phil')

cursor = db.cursor()
cursor.execute('SHOW VARIABLES')
for r in cursor.fetchall():
  webapp2.RequestHandler.response.write('%s\n' % str(r))

db.close()

However I get the error:

`Can't connect to local MySQL server through socket`

1 Answer 1

1

Of course it's possible, but that's the documentation for using it specifically from App Engine. Rather, you should use the docs for connecting from an external application - you'll need to configure access, then set mysqldb to connect via IP rather than a local socket.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.