如何将 SQL 查询限制为非破坏性?
我正计划构建一个具有强大过滤器的 Django 日志查看应用程序。我想让用户能够使用一些自定义(可能是特定于数据库的)SELECT 查询来精细过滤结果。
但是,我不喜欢授予用户对数据库的写访问权限。有没有办法确保查询不会更改数据库中的任何内容?就像“预演”标志一样?或者有没有办法过滤 SELECT 查询,使它们不会以任何方式有害?
我考虑过以单独的 MySQL 用户身份运行查询,但我宁愿避免麻烦。我还考虑过使用 Google App Engine 的 GQL“语言”,但如果有更干净的解决方案,我当然想听听:)
谢谢。
I'm planning on building a Django log-viewing app with powerful filters. I'd like to enable the user to finely filter the results with some custom (possibly DB-specific) SELECT queries.
However, I dislike giving the user write access to the database. Is there a way to make sure a query doesn't change anything in the database? Like a 'dry run' flag? Or is there a way to filter SELECT queries so that they can't be harmful in any way?
I thought about running the queries as a separate MySQL user but I'd rather avoid the hassle. I also thought about using Google App Engine's GQL 'language', but if there is a cleaner solution, I'd certainly like to hear it :)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与仅被授予 SELECT 权限的用户连接。像这样的情况就是权限存在的首要原因。
Connect with a user that has only been granted SELECT permissions. Situations like this is why permissions exist in the first place.
创建和使用不可修改的视图。
Create and use non-modifiable views.