Would it be possible to automatically export a Google sheet to a SQL type database which I could query? I am trying to make a information dashboard out of the sheet that contains data from a Google form. What possible ways could I do this?
2 Answers
If you're ok with the data being public (file>publish as html), you can expose/publish Google sheets as CSV/TSV/etc, then you could automate an import process with that URL as the source.
You can also access the data as JSON which might make the database import unnecessary (assuming the data is on the first sheet) https://spreadsheets.google.com/feeds/list/YOURDOCID/1/public/values?alt=json
I know this has been inactive for a while, but I found this post while searching "Google Sheets to database", and I've tried a few out-of-the-box solutions that solved this problem for me.
Fivetran (https://www.fivetran.com). You can use an ETL solutions like Fivetran which will move the data into a format you can store it (whether it's a SQL database, NoSQL database, or a warehouse). The pro is that it's a robust tool that is built for more than just google sheets too. But it may be a bit over-engineered and expensive for this use case
Airbyte (https://airbyte.com). Airbyte is another ETL solution that is open-source so it will be cheaper than Fivetran. You can also move data from MySQL back into google sheets known as reverse ETL. But you cannot do sync data G-sheets -> SQL and SQL -> G-sheets because you'd get an infinite loop / merge conflicts. Meaning, you wouldn't have a source of truth and know which data should overwrite the other.
Bracket(https://usebracket.com). This is a bidirectional ETL solution. You can move data into one-way (from g-sheets -> SQL or SQL -> G-sheets) but you can also do a two-way sync. Bracket actually allows you to choose a source of truth so you can basically replicate all data from SQL into your G-sheet, and all you G-sheet data into SQL. It also works with NoSQL databases and data warehouses.
Of course you can also write an internal script to dump the data from g-sheets to SQL with some frequency and this is probably the cheapest if you can do it yourself! You just have to maintain it as the APIs change over time