DEV Community

Cover image for Using Google Sheets as a Database: 3 Ways to Connect the API to Node.js

Using Google Sheets as a Database: 3 Ways to Connect the API to Node.js

Steph Smith on May 12, 2019

This was originally published on my blog, where I often write about learning to code, remote work, and women in tech. 3 Approaches for Us...
Collapse
 
ben profile image
Ben Halpern •

Anything can be a database, this is really cool.

Collapse
 
stephsmithio profile image
Steph Smith •

Thank you, Ben!

Collapse
 
evanplaice profile image
Evan Plaice •

You're awesome. This project is awesome.

I did something similar in python a few years ago to do automated document creation.

It turned a few weeks worth of work into a few seconds. This is such a useful tool in the business world where everybody works in spreadsheets.

Collapse
 
stephsmithio profile image
Steph Smith •

Wow, thanks so much Evan! I agree, it's super powerful especially since it's so easy for people who don't code to contribute to and see the data.

Collapse
 
mrdddalkilanny profile image
Ibraheem AlKilanny •

Thats great, but why sheets? Google already provides Firebase which is an NO-SQL cloud database.
Such database is obtimized for loading, writing, search, etc. It is certainly faster than executing sheets in both development and execution.
quran.com/25

Collapse
 
stephsmithio profile image
Steph Smith •

Using Google sheets isn't for every project, but using Sheets is easier for MVPs and simple projects that have a lot of collaboration. Almost every company uses Sheets already and very easy to view/edit the data.

Collapse
 
sandordargo profile image
Sandor Dargo •

Great job! I did something similar in Flutter and at the end with all the synch logic between devices... Well, it was a good learning experience. For my next app, I used Firebase. I found it much-much-much easier.

Thread Thread
 
stephsmithio profile image
Steph Smith •

Super cool!

Collapse
 
devpato profile image
Pato •

I remember when I was in college for my Software Engineer class we had to create a Ebay replica and you will get extra points if you used Google Sheets as a DB. We were the only team that did, which it was awesome but Google Sheets was to extremely slow :( but hey! it was fun to learn.

Also I have been several years in the industry and I have never heard of anyone using Google Sheets as a database in a production application. Could you provide me some example of companies or apps that use it in production? I want to do research on how they did it and why, would be super interesting to see if I can apply it to a future project :)

A few questions:
Is there a reason why you are mixing var and const?
Is there a reason why you are mixing fat arrow function vs normal function?

Thanks so much for the post. Keep the good work!

Collapse
 
stephsmithio profile image
Steph Smith •

I don't think many production applications use it as a database to be honest. I'm sure there are, but I'm not familiar with which ones!

One thing I've been thinking about is actually using Google Sheets as a database, but then running cron jobs to "save" the info into a more traditional database, to improve with speed.

As for your questions, I really shouldn't be mixing the functions and var/const. I typically write normal functions, so anything you see that's a normal function was probably code written by me. In a few cases, the arrow functions were probably the snippet code copied from Google's API docs. :)

Collapse
 
_justirma profile image
Irma Mesa •

Really neat, Steph! Saw you post this on Women Make and I was super impressed. I'm currently learning Node.js and it's awesome seeing what you've built in using it.

Collapse
 
stephsmithio profile image
Steph Smith •

Thanks Irma!! Love that you're learning Node as well. If you want to join, I set up another Telegram group of ~50 of us learning to code (many learning JS/Node). That's where the inputs from Progression Page came from โ˜บ๏ธ

Collapse
 
_justirma profile image
Irma Mesa •

I'd love to join, Steph! :) Let me know how I can join the Telegram group.

Thread Thread
 
stephsmithio profile image
Steph Smith •

You can join us here!

t.me/joinchat/IZhyDBT6OwaAdaIHADbFQw

Collapse
 
rohovdmytro profile image
Rohov Dmytro •

I am very, very curious how many websites are using Google Sheets for this type of usecase. I am very interested in some surveys on data about this.

I think it's not that small amount of people.

Collapse
 
stephsmithio profile image
Steph Smith •

Yes, I am seeing lots of people utilizing it more these days! Would be interested to see data as well.

Collapse
 
ianrathbone profile image
Ian Rathbone •

Love the notion of using google sheets as a database! Youโ€™ve got me tempted to do something now...

Collapse
 
stephsmithio profile image
Steph Smith •

Thanks Ian! Excited to see what you make! ๐Ÿ˜€

Collapse
 
zizaco profile image
Zizaco •

This is awesome! :D

Collapse
 
stephsmithio profile image
Steph Smith •

Thank you!

Collapse
 
bhupesh profile image
Bhupesh Varshney ๐Ÿ‘พ •

Nice ๐Ÿ‘Œ idea
But wouldn't it be difficult when you want to create some complex relationship like foreign keys and etc
๐Ÿค”๐Ÿค”

Collapse
 
stephsmithio profile image
Steph Smith •

I definitely think there are cases where you can't utilize Google Sheets as a DB, but I think it's good for MVPs and collaborative projects where multiple people need access to view/change the data easily. ๐Ÿ™‚

Collapse
 
devpato profile image
Pato •

uhmm interesting. I don't really think that happens in a real app production app. Not everyone should be touching the database, specially if you only have one version and can't give roles to it which I believe that the case for Google Sheets. If you want to use a database just to view/change data might as well use a normal sql database and use app to view it in a table grid form like MySQL workbench does. This app will give you a similar feeling to Google Sheets via displaying the data in a grid.

Collapse
 
stephsmithio profile image
Steph Smith •

Amazing!