我可以让 Google Drive 电子表格像 MySQL 数据库一样工作吗?
我可以像使用(类似于)MySQL 数据库一样使用 Google Drive 电子表格吗?
Can I use a Google Drive spreadsheet as if it were (similar to) a MySQL database?
我正在考虑将其用作 HTML/JavaScript 网页游戏的玩家数据库.玩家的用户名、密码和分数等将保存在数据库中.如果它真的可以工作,那将是非常有趣的,但是它当然必须是安全和私密的,这样除了电子表格的所有者(例如我)之外,没有玩家(或互联网上的任何人)可以访问它.
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.
我知道 Google Apps 脚本允许用户访问他们自己的电子表格并对其进行读/写,但是有没有一种方法可以让其他用户在我的电子表格中保存他们的分数"而不授予他们查看权限/直接编辑电子表格?
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?
另外,我假设必须使用 PHP/Python/其他一些服务器端语言来隐藏我的帐户信息,我还假设需要这些信息来打开和关闭与我的电子表格的连接.
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.
无论如何,我只是想知道这是否可行.实际上将 Google Drive 电子表格变成了一个数据库,玩家可以更新他们的分数,但不能直接访问它.
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!
提前致谢!
推荐答案
回答说您需要额外的服务器或 oauth 不正确.只需使用您的权限发布一个 appscript(匿名公共)服务.对于所有操作,始终传递用户名和密码,因此您可以在每次调用时验证用户.使用 ajax 从客户端 js 调用服务.将其存储在 scriptdb [更新:scriptDb 现已弃用].如果您使用电子表格进行存储,它会因行数过多而变慢.
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.
无论如何,如果你使用 appscript,它会很慢.
In any case it will be slow if you use appscript.
相关文章