最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I make Google Drive Spreadsheets act like a MySQL database? - Stack Overflow

programmeradmin4浏览0评论

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!

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!

Share Improve this question asked Apr 13, 2013 at 8:29 JacobJacob 3,9658 gold badges26 silver badges25 bronze badges 8
  • 2 Why do you want to store your data in a Google Spreadsheet? The best MySQL emulator is MySQL itself. Google offers this as a service: Cloud SQL: developers.google.com/cloud-sql Google also offers App Engine, which has its own database, called Datastore: developers.google.com/appengine/docs/python/datastore It accepts some SQL-like queries. – allyourcode Commented Apr 13, 2013 at 10:25
  • Also, if you have to use Apps Script for this, there's ScriptDB that you can use for storage. – Fred Commented Apr 13, 2013 at 12:21
  • 1 @allyourcode I was just interested in exploring the possibility. Thanks for the links, I didn't realize CloudSQL existed! – Jacob Commented Apr 13, 2013 at 17:39
  • @Frederic yes, but is it possible that users could get access to ScriptDB through javascript and be able to view the table and therefore everyone's passwords? – Jacob Commented Apr 13, 2013 at 17:44
  • @Jacob I suppose you could try to build a bicycle out of uncooked spaghetti, but why? Spaghetti is not meant for that sort of thing. Stick with more reasonable materials like aluminum. – allyourcode Commented Apr 13, 2013 at 18:03
 |  Show 3 more comments

3 Answers 3

Reset to default 6

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.

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.

Without a server-side service that implements another authentication layer for client libraries and use Google auth to talk to Drive, this is not possible.

发布评论

评论列表(0)

  1. 暂无评论