Connecting from App Engine

This page provides language-specific links to information about how to set up a connection from an App Engine application and a PostgreSQL instance.

For information about the various options for connecting to Cloud SQL, see Connection Options for External Applications.

General information for connecting to Cloud SQL from App Engine

When you are connecting to Cloud SQL from App Engine, keep these best practices in mind:

  • App Engine has the ability to automatically create more instances when load increases. If the number of App Engine instances increases beyond what the Cloud SQL instance is sized to handle, your Cloud SQL instance will not be able to meet the demand. You can avoid this issue by setting the max_instances value for the basic_scaling element in your app.yaml file. For more information, see Scaling elements.
  • Open database connections consume resources; your application should always close connections when they are no longer being used. For App Engine standard environment, there is a hard limit on the number of connections an App Engine instance can have open to Cloud SQL. If your application requires more open connections, consider using connection pooling.

App Engine standard environment to PostgreSQL

For information about connecting from App Engine standard environment to Second Generation instances, see the App Engine documentation for your programming language:
Language Documentation
Java Using Cloud SQL for PostgreSQL with Java
Node.js Using Cloud SQL for PostgreSQL with Node.js

App Engine flexible environment to PostgreSQL

For information about connecting from App Engine flexible environment to PostgreSQL instances, see the App Engine documentation for your programming language:
Language Documentation
Python Using Cloud SQL for PostgreSQL with Python
Java Using Cloud SQL for PostgreSQL with Java
Node.js Using Cloud SQL for PostgreSQL with Node.js
Go Using Cloud SQL for PostgreSQL with Go
Ruby Using Cloud SQL for PostgreSQL with Ruby
PHP Using Cloud SQL for PostgreSQL with PHP
.NET Using Cloud SQL for PostgreSQL with .NET

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud SQL for PostgreSQL