Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make Google Drive Spreadsheets act like a MySQL database?

Tags:

Can I use a Google Drive spreadsheet as if it were (similar to) a MySQL database?

I'm thinking of using it as a player database for an HTML/JavaScript web game. The player's username, password, and score among other things would be saved in the database. It would be really interesting if it could actually work, however it of course has to be secure and private so that no player (or anyone on the internet for that matter) can access it except the owner of the spreadsheet which would be me for example.

I know that Google Apps Script allows a user to access their own spreadsheet and read/write to it, but is there a way that I could allow other users to "save their score" to MY spreadsheet WITHOUT giving them permission to view/edit the spreadsheet directly?

Also, i'm assuming PHP/Python/some other server-side language would have to be used in order to hide my account info which I also assume would be needed to open and close the connection with my spreadsheet.

Anyways, I'm just wondering if this is feasible.. literally turning a Google Drive spreadsheet into a database that players can update their score to but not have direct access to it.

This may be a stupid idea, so your opinions are welcome!

Thanks in advance!

like image 241
Jacob Avatar asked Apr 13 '13 08:04

Jacob


People also ask

Can Google Sheets act as a database?

Did you know Google Sheets can be used as a lightweight database? Google Sheets is a cloud-based spreadsheet application that can store data in a structured way just like most database management systems. You can also edit and delete data with a couple of clicks and, on top of that, access your data online.

Can you use Google Drive as a database?

Yes, it's possible to do that. It will work fine, because each user has their own data in their own drive. You can store as much data you want in that special folder, as long as it doesn't fill the entire drive quota.


2 Answers

This is the right way to do it. Another post explaining the same idea. Essentially, we publish the spreadsheet and query it using a "select"-like syntax. For instance: this query which reads something like:

https://spreadsheets.google.com/tq?tqx=out:html&tq=select+B,C,I&key=phNtm3LmDZEObQ2itmSqHIA

This is for querying data (reading). For inserting, you can use google forms (create a form, see its html and submit using a http post request). I have not explored update yet.

And yes, this has to be done server side.

like image 176
Jus12 Avatar answered Sep 30 '22 03:09

Jus12


Answers saying you need an extra server or oauth are incorrect. Just publish an appscript (anonymous public) service using your permissions. For all operations always pass the username and password thus you validate users on every call. Call the service from client js using ajax. Store it in scriptdb [update: scriptDb is deprecated now]. If you use spreadsheet for storage it will get slow with many rows.

In any case it will be slow if you use appscript.

like image 38
Zig Mandel Avatar answered Sep 30 '22 02:09

Zig Mandel