🔄

Sync data from Google Sheets to SQL

💡

The database user for this source will need write access to the database. If you need to add / insert rows, consider using a

instead

You can sync data from a Google Sheet back to your database using the

, to get started, install the addon. Updates are triggered as soon as an edit in the Sheet is completed, so the updates write back to your database in near real time.

  1. Create a new SQL block with
    Parameters
    . It's best to give the parameter the same name as the column, e.g.
  2. update dummy.users 
    set plan = '{{plan}}' 
    where email = '{{email}}'
  3. Add the form tag
  4. image
  5. Launch the addon
  6. Select the block created in step #1 (you should see "Form" to the right of it)
  7. image
  8. Click "Set up a sync" under the Run button
  9. image
  10. Add the range that your data is in, e.g. "Sheet1!A:G". You need to include the cell range using A1 notation. Your table in sheets needs to have headers / column names
  11. 💡

    You can only have one sync per sheet, but you can have multiple syncs in the same spreadsheet.

    image
  12. If the table in Sheets has different column names then your parameters, specify the names under each parameter name.
  13. Click Save
  14. Done! You can now test your sync by updating a value in the Sheet and confirming the write back to your database. Please let us know if you run into any issues with this.

image

Handling null data

Numbers

CAST('{{your_param}}' AS SIGNED INTEGER)

Upserts

MySQL

INSERT INTO books
    (id, title, author, year_published)
VALUES
    ({{id}}, '{{title}}', '{{author}}', '{{year_published}}')
ON DUPLICATE KEY UPDATE
    title = '{{title}}',
    author = '{{author}}',
    year_published = '{{year_published}}';