How to get a Python datatype from a SQLAlchemy query? -
i have (sqlite3) database numeric(10, 2)
field. want query , work standard python datatype (for me <class 'float'>
). in code below want list of floats - nothing more. how can without manual converting list?
# python3 pseudocode class model(_base): __tablename__ = 'model' ... _weight = sa.column('weight', sa.numeric(10, 2)) ... query = session.query(model._weight) result = query.all() print(type(result)) print(type(result[0])) print(type(result[0][0]))
this result can not work with
<class 'list'> <class 'sqlalchemy.util._collections.result'> <class 'decimal.decimal'>
when use numeric(10, 2, asdecimal=false)
, int
returned. know sqlite can not handle float numbers.
btw. want work float numbers in matplotlib.
Comments
Post a Comment