使用python脚本在使用postgresql的复制命令(Amazon Redshift)时跳过固定宽度文件中的坏行

发布于 2025-01-21 12:29:40 字数 144 浏览 2 评论 0原文

我正在使用psycopg2连接到红移数据库。我想运行复制查询以将固定宽度文件加载到表中,但是其中一些文件的行中有错误。复制当前在第一个错误上断开,我想使用python脚本跳过这些不良行,记录错误并继续加载数据。 这是否建议(如良好的实践/大会)吗?如果是这样,我该如何处理?

I am using psycopg2 to connect to a redshift database. I would like to run COPY queries to load fixed width files into tables, but some of these files have rows with errors in them. COPY currently breaks on the first error, and I would like to use a python script to skip these bad rows, log the error, and continue loading the data.
Is this advisable (as in good practice/convention)? If it is, how do I go about it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文