Jaimy Azle wrote: > Hi, > > I have a problem on using Decimal type along with SQLAlchemy, the > decimal value could not be used for any computation after querying > something with SQLAlchemy object. This is reproducable in my machine: > > import decimal > from tbl import SBCITM > > pval = decimal.Decimal(decimal.Decimal('0.999') * 99) > print 'value of type %s was %s' % (type(pval), pval) > > obj = SBCITM.query.filter_by(SCITKYID = 3).first() > if not obj: > raise Exception('record id could be found in the database') > > pval = decimal.Decimal(decimal.Decimal('0.999') * 99) > print 'value of type %s was %s' % (type(pval), pval) > > output from the script: > >>> value of type <class 'decimal.Decimal'> was 98.901 >>> value of type <class 'decimal.Decimal'> was 1E+2
Could be something in the MSSQL db-api driver changing the decimal context- replacing the query code with the following gives me the same result: decimal.getcontext().prec = 1 --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---