This repo is a script to sync data from a Google Drive spreadsheet to Stitch.
PLEASE NOTE:
This script is not supported by Stitch as an integration. Please feel free to contribute to this repository.
This connector assumes you have headers in in the spreadsheet in row 1 of the spreadsheet.
This connector will not work if you define more than 8 columns as keys.
The tab name must only include alpha-numeric characters. Remove spaces, or replace with underscores.
You should make sure to set the columns to the correct data formats. For example, if a column contains all integers, please make sure it is not formatted as plain text.
-
Open the spreadsheet you would like to sync to Stitch.
-
Click Tools, Script Editor. Click Close on the Popup, or choose blank project.
-
In the "Run" menu, click "Disable new Apps Script runtime powered by V8".
-
Delete the contents of the file currently open
-
Copy the contents from this folders's sheetstostitch.gs page, and paste into the 'code.gs' script file you have open.
-
Go back to the spreadsheet and refresh the page. If you don't see a new dropdown in the toolbar titled "Stitch Import", close the spreadsheet and re-open it.
-
In the "Stitch Import" dropdown, click "Set Stitch API credentials". You'll need to authorize the script to access the data, so log in with the Google account that has access to this sheet.
-
Enter API key and Client ID provided in your Stitch account.
-
In the "Stitch Import" dropdown, click "Set this sheet's primary key".
-
Choose which columns act as the unique key for your table. These columns must be unique for all current and future rows of this table. If you have multiple columns that make up the unique key, it's recommended that you hash them together using the md5 Google Sheets function.
To use this handy function in Google Sheets, enter the contents of the md5_sheets.gs file into Tools --> Script Editor. Then, to create a unique key in your sheet based on multiple columns, create an 'ID' column and in its cells enter " =md5(cell1&cell2&cellN) " where cells 1,2...N are the cells that make up your unique key. Make sure to format numbers or dates as text before using them in an md5 function to ensure the data being used to generate your unique key are in a specified format. If you plan to join this table to other data models based on this key, make sure the output matches what your warehouse generates from "select md5('cell1 contents' || 'cell2 contents' || 'cellN contents')". For more information on the function and its uses, check here and here.
If you store data in another tab that you would like to also sync to the Stitch Import API, you'll need to set up the keys in that sheet as well. You can do so by clicking on that tab, and following the directions below.
- In the "Stitch Import" dropdown, click "Set this sheet's primary key".
- Choose the keys(s) in this tab that make each row unique. Enter the relevant column headers exactly as you have them in the sheet. If more than one, it's recommended that you hash them together using the md5 Google Sheets function.
- Once you are ready to sync data to Stitch, select the sheet/tab you want to sync.
- In the "Stitch Import" dropdown, click "Sync this sheet to Stitch".
- Once data has replicated to your warehouse, query it to make sure it looks right and has all of the rows you need.
If you encounter any errors, please open an issue in this repo. If you find a solution to a problem, submit a pull request.
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.