快速简便的数据导入工具/库

发布于 2024-12-07 09:16:43 字数 203 浏览 4 评论 0原文

我正在寻找允许快速(轻松)将数据导入现有数据库表的工具/库。例如,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是我的挚爱i 2024-12-14 09:16:43

您可以使用 PostgreSQL 中的标准工具完成所有这些工作,无需额外的库。

对于 .csv 文件,您可以使用内置的 复制命令。 COPY 快速且简单。为此,源文件必须与数据库位于同一台计算机上。如果没有,您可以使用 psql< 的非常相似的 \copy 元命令/a>.

对于 .xml 文件(或任何格式),您可以使用内置的 pg_read_file() 位于 plpgsql 函数。不过,我引用一下:

仅限数据库集群目录和 log_directory 中的文件
可以访问。

因此,您必须将源文件放在那里或创建指向实际文件/目录的符号链接。然后你可以用 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:

Only files within the database cluster directory and the log_directory
can be accessed.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文