8

I have a webapp that spans many different users, each with selective permissions about what they are able to see. The app is built on top of a MySQL database.

One feature I am interested in providing to my "power users" is a sql dump of all their data so that they can run off and do their own things with it. Now I can't just use mysqldump because there are things belonging to other users that should not be made available to anybody else on download.

Is there any other easy way to get data in and out of MySQL that allows you to selectively specify what to export, and without having to jump through all kinds of hoops? Note that I need control at the query level - i.e. being able to specify a list of tables is NOT sufficient. In an ideal world, such a tool would automatically find all relationships based on traversal of foreign keys, but if I have to write queries at the table-level I'm willing to, provided it's easy for others to get the data back into mysql without too much trouble.

Anyone know if such a tool exists, or if I am in "roll my own" territory?

4

2 回答 2

5

Mysqldump 确实有一个“--where”标志,您可以使用它来选择性地返回行。我认为您应该能够执行以下操作:

mysqldump --where="foreign_key_id=5"

哪个应该只返回那些特定的行,MySQL站点上的更多文档

但是,我不确定您是否会更进一步将导出为逗号分隔值文件。CSV 文件可以重新导入 MySQL,并为您的用户提供许多其他选项来处理他们的数据(电子表格、其他 RDBMS、文本分析)。

于 2010-02-02T20:33:11.970 回答
0

这是一个工具,可以帮助您将数据导出为 CSV/Excel 文件,但不能导入数据。它具有权限管理,应提供您所需的必要访问权限。

你可以在这里找到它:https ://github.com/mpetcu/report-manager 。

于 2016-03-23T11:36:23.550 回答