python - sqlalchemy.exc.DataError: (psycopg2.DataError) integer out of rang -
i trying save data postgresql via sqlchemy orm. encountered error below: sqlalchemy.exc.dataerror: (psycopg2.dataerror) integer out of range
i pinpoint place goes wrong. have large number 2468432255.0. if change smaller number 468432255.0, works.
the thing confused me that: define column volume = column(numeric). far understand, numeric should able handle large number. additionally, tried other data type bigint etc... gave me same error.
any idea?
thanks, chengjun
you can define want in sqlalchemy schema in local code, doesn't mean honored db you're inserting data into.
the schema defined in sqlalchmey - being enforced code itself
while db has it's own schema encforing when you're trying insert/delete etc .. ( has it's own constraints etc .. ) sqlalchemy knows nothing ( until declare )
in opinion can generate sqlalchemy schema automatically - , take db column name & types db schema.
from sqlalchemy import create_engine class sometable(base): """ class, represents sometable """ __tablename__ = "my_table_in_db" __table__ = table(__tablename__, base.metadata, autoload=true, autoload_with=create_engine(db_url))
and after you'll create sometable
object, can access columns by
sometable.colname
colname
column exists in db
Comments
Post a Comment