简体   繁体   English

sqlalchemy获取``整数超出范围''错误

[英]Getting 'integer out of range' error sqlalchemy

So, I am using odo for data migration but came across this error: 因此,我使用odo进行数据迁移,但是遇到了此错误:

sqlalchemy.exc.DataError: (psycopg2.DataError) integer out of range  

Both the source and the destination tables have the same schema but in the sql statement being executed in the backend the integer values have .0 with them. 源表和目标表都具有相同的架构,但是在后端执行的sql语句中,整数值带有.0。 Like the integer 34 in the source table is shown as 34.0 : 就像源表中的整数34显示为34.0

[SQL: INSERT INTO table2 (col1, col2,col3) VALUES (%(col1)s, %(col2)s, %(col3)s] 
[parameters: ({'col2' : val2', 'col3' : val3', 'col1' : val1})]

Please let me know if more information is needed. 请让我知道是否需要更多信息。

The sql string should be: sql字符串应为:

INSERT INTO table2 (col1, col2, col3) VALUES (
    %(col1)s::numeric::int, 
    %(col2)s::numeric::int, 
    %(col3)s::numeric::int
)

If the target column is not nullable and the source value can be None then coalesce it: 如果目标列不可为空并且源值可以为None则将其合并:

    coalesce(%(col1)s::numeric::int, 0), 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM