Hello,

I am inserting float data into a MySQL column of type DOUBLE. The data gets inserted properly (verified via mysql terminal). Querying for the object returns a Decimal object, but the number of digits after the decimal point if always limited to 11 (while DOUBLE supports 15 by default). So, what can I do to get the correct value? I have played with the precision and scale arguments for DOUBLE without effect.

Here's an example:


from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.engine import create_engine
from sqlalchemy.orm.session import sessionmaker
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer

from sqlalchemy.dialects.mysql.base import DOUBLE

Base = declarative_base()


class SomeClass(Base):
    __tablename__ = 'someclass'
    id = Column(Integer, primary_key=True)
    value = Column(DOUBLE)

engine = create_engine('mysql://user:pass@localhost/test', echo=True)
Base.metadata.create_all(engine)
s = sessionmaker(engine)()
r = SomeClass(value=0.1234567891234567)
s.add(r)
s.commit()
x = s.query(SomeClass).get(1)
print x.value

Regards

Sebastian

--
check out www.pointcloud9.com

Sebastian Elsner - Pipeline Technical Director - RISE

t: +49 30 20180300 flor...@risefx.com
f: +49 30 61651074 www.risefx.com

RISE FX GmbH
Schlesische Strasse 28, Aufgang B, 10997 Berlin
c/o action concept, An der Hasenkaule 1-7, 50354 Hürth
Geschaeftsfuehrer: Sven Pannicke, Robert Pinnow
Handelsregister Berlin HRB 106667 B

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to