I have a schema with a Float column, something like this:
Base = declarative_base()
class Table(Base):
__tablename__ = 'table'
id = Column(Integer,primary_key=True)
amount = Column(Float(16,2))
When I commit some rows to this table, sqlalchemy rounds the floating point numbers to integers:
t = Table()
t.amount = 2.25
session.add(t)
# right here, t.amount is still 2.25
session.commit()
# here, t.amount is already 2
Doing some SQL on my DB gives this:
SELECT * FROM Table
id | amount
-------------
1 | 2
Is there a reason that this may be happening? Some missing or wrong configuration? I have also tried using Numeric data type, but the result is the same
I'm using sqlalchemy 0.8.2 with a MySQL db here