我可以让 Google Drive 电子表格像 MySQL 数据库一样工作吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15985837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I make Google Drive Spreadsheets act like a MySQL database?
提问by Jacob
Can I use a Google Drive spreadsheet as if it were (similar to) a MySQL database?
我可以像使用(类似于)MySQL 数据库一样使用 Google Drive 电子表格吗?
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.
我正在考虑将其用作 HTML/JavaScript 网页游戏的玩家数据库。玩家的用户名、密码和分数等将保存在数据库中。如果它真的可以工作,那将会非常有趣,但是它当然必须是安全和私密的,这样除了电子表格的所有者(例如我)之外,没有玩家(或互联网上的任何人)可以访问它.
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?
我知道 Google Apps Script 允许用户访问他们自己的电子表格并对其进行读/写,但是有没有一种方法可以让其他用户将他们的分数“保存”到我的电子表格中,而无需授予他们查看/编辑直接用电子表格?
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.
另外,我假设必须使用 PHP/Python/其他一些服务器端语言来隐藏我的帐户信息,我还假设需要打开和关闭与我的电子表格的连接。
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.
无论如何,我只是想知道这是否可行......实际上将 Google Drive 电子表格转换为一个数据库,玩家可以将其分数更新到但不能直接访问它。
This may be a stupid idea, so your opinions are welcome!
这可能是一个愚蠢的想法,所以欢迎您的意见!
Thanks in advance!
提前致谢!
采纳答案by Zig Mandel
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.
回答说您需要额外的服务器或 oauth 是不正确的。只需使用您的权限发布 appscript(匿名公共)服务。对于所有操作,始终传递用户名和密码,因此您可以在每次调用时验证用户。使用ajax从客户端js调用服务。将其存储在 scriptdb [更新:现在不推荐使用 scriptDb]。如果您使用电子表格进行存储,多行会变慢。
In any case it will be slow if you use appscript.
无论如何,如果您使用 appscript,它会很慢。
回答by Jus12
This is the right way to do it.Another postexplaining the same idea. Essentially, we publish the spreadsheet and query it using a "select"-like syntax. For instance: this querywhich 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.
这是用于查询数据(读取)。对于插入,您可以使用谷歌表单(创建一个表单,查看其 html 并使用 http post 请求提交)。我还没有探索更新。
And yes, this has to be done server side.
是的,这必须在服务器端完成。
回答by Burcu Dogan
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.
如果没有为客户端库实现另一个身份验证层并使用 Google 身份验证与云端硬盘对话的服务器端服务,这是不可能的。