神秘的 Psycopg2 错误消息
我正在将 Psycopg2 与 PostgreSQL 8.4 一起使用。在从一个巨大的表中读取数据时,在同一行代码成功获取了几十万行之后,我突然在以下代码行中遇到了这个神秘的错误。
somerows =cursorToFetchData.fetchmany(30000)
psycopg2.DataError:“DD”的值“Là”无效
详细信息:值必须是整数。
我的问题是我没有名为“DD”的列,并且该表中有大约 300 列(我知道 300 列是一个设计缺陷)。我希望能得到有关此错误消息的含义的提示,或者如何找出问题所在。我不明白 Psycop2 在获取行时如何对数据类型有任何要求。
I am using Psycopg2 with PostgreSQL 8.4. While reading from a huge table, I suddenly get this cryptic error at the following line of code, after this same line of code has successfully fetched a few hundred thousand rows.
somerows = cursorToFetchData.fetchmany(30000)
psycopg2.DataError: invalid value "LÃ" for "DD"
DETAIL: Value must be an integer.
My problem is that I have no column named "DD", and about 300 columns in that table (I know 300 columns is a design flaw). I would appreciate a hint about the meaning of this error message, or how to figure out where the problem lies. I do not understand how Psycop2 can have any requirements about the datatype while fetching rows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是 psycopg 错误,而是 postgres 错误。
引发错误后,查看 cur.query 以查看生成的查询。将其复制并粘贴到 psql 中,您将看到相同的错误。然后从那里调试它。
This is not a psycopg error, it is a postgres error.
After the error is raised, take a look at cur.query to see the query generated. Copy and paste it into psql and you'll see the same error. Then debug it from there.
您可以粘贴导致问题的行中的数据吗?我猜测这是一个格式错误的日期条目,但很难说。
(无法发表评论,所以必须在答案中......)
Can you paste in the data from the row that's causing the problem? At a guess I'd say it's a badly formatted date entry, but hard to say.
(Can't comment, so has to be in a answer...)