Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Batch Workflow SQL access

I am following this tutorial, and it works great for me. Until I try to connect to my PostgreSQL database.

https://cloud.google.com/workflows/docs/tutorials/batch-and-workflows

How to add a database connection that works?

 

1 1 277
1 REPLY 1

Hi @OlgaP,

Welcome to Google Cloud Community!

You're having trouble connecting to a PostgreSQL database in your Google Cloud Batch Workflow. Here are two options:

1. Use Cloud SQL Connector for Python:

  • Simplest option, but requires Python application and pg8000 driver.

2. Use Cloud SQL Auth Proxy container:

  • More complex, but works with any database driver.

Steps for option 2:

  1. Create Cloud SQL Proxy instance.
  2. Set environment variables for app to connect to Proxy.
  3. Add Proxy container to batch job definition.

For detailed instructions, check these resources: