Reputation: 377
How to have a unsigned float data type in python - sqlalchemy framework?
I am using Integer type, which results in a Warning: Out of range value for column 'xxxx' at row 1 cursor.execute(statement, parameters)
.
I am implementing the table like this :
class testTable(Base):
__tablename__ = 'test_table'
id = Column(Integer, primary_key=True)
xxxx = Column(Integer, ForeignKey('another.id'))
yyyy = Column(Integer, nullable=False)
.
.
.
MySQL is the database server.
Upvotes: 2
Views: 14485
Reputation: 8587
Looking at the documentation reveals there is the Float
type.
from sqlalchemy import Float
(...)
class testTable(Base):
__tablename__ = 'test_table'
id = Column(Integer, primary_key=True)
xxxx = Column(Integer, ForeignKey('another.id'))
yyyy = Column(Integer, nullable=False)
zzzz = Column(Float)
For MySQL specifics such as unsigned
, refer to the respective documentation, e.g. importing the specific UPPERCASE types:
from sqlalchemy.dialects.mysql import FLOAT
You can then use these to create your Column as usual:
zzzz = Column(FLOAT(unsigned=True))
Upvotes: 10