Thanks for responding, I am using Postgresql 8.3.8 and Postgis 1.4. I have tried using both DOUBLE_PRECISION and DOUBLE_PRECISION(asdecimal=True), with the same errors.
thanks On Jan 18, 3:50 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > Here's a tested example of DOUBLE_PRECISION using both float and Decimal > versions. Make sure you're on a recent release of psycopg2: > > from sqlalchemy import Column, create_engine, Integer > from sqlalchemy.orm import Session > from sqlalchemy.ext.declarative import declarative_base > from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION > from decimal import Decimal > > Base = declarative_base() > > class dream4_eta_15km_pm10(Base): > __tablename__='pm10_dream_rasters' > > id = Column(Integer, primary_key=True) > > # use float values > max_pm10=Column(DOUBLE_PRECISION) > > # use Decimal values > mean_pm10=Column(DOUBLE_PRECISION(asdecimal=True)) > > def __repr__(self): > return "dream4_eta_15km_pm10(%r, %r)" % (self.max_pm10, self.mean_pm10) > > engine = create_engine('postgresql://scott:tiger@localhost/test', echo=True) > > Base.metadata.create_all(engine) > > sess = Session(engine) > > sess.add(dream4_eta_15km_pm10(max_pm10=76945.283959, > mean_pm10=Decimal("7683.27835"))) > > sess.commit() > > print sess.query(dream4_eta_15km_pm10).all() > > On Jan 18, 2011, at 3:24 PM, wilbur wrote: > > > Hello, > > > I am having problems using sqlalchemy to write values to Postgresq > > columns of type Float. I am getting "sqlalchemy.exc.ProgrammingError: > > (ProgrammingError) can't adapt" errors when I try to insert records. > > > My Postgresql table is defined as: > > > Column | Type > > | Modifiers > > ----------------+-------------------------------- > > +------------------------------------------------------------------ > > max_pm25 | double precision | > > mean_pm25 | double precision | > > > After importing the Postgresql dialect: > > > from sqlalchemy.dialects.postgresql import * > > > I define my sqlalchemy table as: > > > class dream4_eta_15km_pm10(Base): > > __tablename__='pm10_dream_rasters' > > max_pm10=Column(DOUBLE_PRECISION) > > mean_pm10=Column(DOUBLE_PRECISION) > > > Any help appreciated, > > > Bill > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to sqlalchemy@googlegroups.com. > > To unsubscribe from this group, send email to > > sqlalchemy+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.