How To

How to connect Google Sheets to a database

Ian Yanusko
December 20, 2022
4
min read

Google Sheets is a great tool for creating and managing spreadsheets. But what if you want to connect your Google Sheets spreadsheet to a database?

Why would I want to do this?

1. There are plenty of cases where your business teams need to track product & customer data. Think about your Customer Success team tracking user onboarding and turning feature flags on and off, or your Ops team tracking the status of customer orders. 

2. You have two options to get this data to and from your business teams: connect an existing tool, like G Sheets, which is the go-to data tool for business users across the globe, or build internal tools from scratch. Here are the pros and cons of each approach:

Okay, I’ll just use Google Sheets. How do I do it?

You could write a script to automate CSV exports from your database, then write an additional Python script (like this) to automate ingestion of the CSV into G Sheets. But if that sounds like too much work, or if you need some fields to sync bidirectionally, you should just use Bracket.

All you need to get started are the connection details for your database (for example, your Postgres connection URI) and a G sheet that’s empty except for column names. Then enter those details on Bracket, customize your sync options and fields to sync, and initiate. 

In about 90 seconds, you have a replacement for an internal tool that could have cost you days if not weeks of implementation, change management, and maintenance. Plus your business teams are going to love you.

But what about field types?

A common concern with Google Sheets is that it’s too free-form. Unless a tool like Airtable, where fields are typed, Google Sheets allows any values in any cell. 

If you’re just syncing from your database to Google Sheets, then this isn’t a problem. If you’re syncing back to your database, though, here’s how you can prevent things from getting messy:

  1. With Bracket, syncs to typed databases will reject any changes that don’t fit the stated types. For example, if you try to sync a Google Sheets number to a Postgres boolean field through Bracket, your change will not persist, and the attempted change will get overwritten with the Postgres value at the next sync. 
  2. If you’re working with untyped databases like MongoDB, you can also take advantage of enum values in Google Sheets. For example, you can force drop-down functionality on your business users with data validation rules
  3. Or, if you want to keep faulty records from being written to your untyped DB, try putting schema validation on the database itself (here’s how to do it for MongoDB). We’re working on a way to enforce this validation at the sync step, stay tuned!

Curious to see Bracket in action? Check out the Snowflake <> Google Sheets demo below, and get started for free here.

Snowflake <> Google Sheets Loom Demo