快速简便的数据导入工具/库
我正在寻找允许快速(轻松)将数据导入现有数据库表的工具/库。例如,phpmyadmin 允许从 .csv、.xml 等导入数据。在 Hadoop Hue 中,通过 Beesvax for Hive,我们可以从文件创建表。我正在寻找可以与 postgresql 或库一起使用的工具,这些工具可以快速轻松地完成此类操作 - 我正在寻找避免手动编码(从读取文件到通过 jdbc 插入数据库)的方法。
I'm looking tools/libraries which allows fast (easy) data import to existing database tables. For example phpmyadmin allows data import from .csv, .xml etc. In Hadoop hue via Beesvax for Hive we can create table from file. I'm looking tools which I can use with postgresql or libraries which allows doing such things fast and easily - I'm looking for way to avoid coding it manualy from reading file to inserting to db via jdbc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 PostgreSQL 中的标准工具完成所有这些工作,无需额外的库。
对于 .csv 文件,您可以使用内置的 复制命令。 COPY 快速且简单。为此,源文件必须与数据库位于同一台计算机上。如果没有,您可以使用 psql< 的非常相似的 \copy 元命令/a>.
对于 .xml 文件(或任何格式),您可以使用内置的 pg_read_file() 位于 plpgsql 函数。不过,我引用一下:
因此,您必须将源文件放在那里或创建指向实际文件/目录的符号链接。然后你可以用 unnest() 和 xpath() 和朋友们。为此,您至少需要 PostgreSQL 8.4。
在 Scott Bailey 的博客文章。
You can do all that with standard tools in PostgreSQL, without additional libraries.
For .csv files you can use the built in COPY command. COPY is fast and simple. The source file has to lie on the same machine as the database for that. If not, you can use the very similar \copy meta-command of psql.
For .xml files (or any format really) you can use the built in pg_read_file() inside a plpgsql function. However, I quote:
So you have to put your source file there or create a symbolic link to your actual file/directory. Then you can parse it with unnest() and xpath() and friends. You need at least PostgreSQL 8.4 for that.
A kick start on parsing XML in this blog post by Scott Bailey.