On Jul 6, 2011, at 12:57 PM, emmanuel CAZENAVE wrote:

> Hello,
> 
> I'm facing problems with mssql+pymssql: it seems that pymssql has poor 
> decimal support.
> As a result there are some rounding differences between the values stored in 
> the database, and the values I get when querying through mssql+pymssql. And I 
> absolutely need the exacts values stored in the DB.
> 
> I'm thinking of a workaround: is it possible to declare every Decimal column 
> as String in  my alchemy's column definitions and manually cast the results 
> in decimal (or maybe at a lower level: in the column_property for example ?). 
> The goal would be to 'get rid' of conversion to float made by pymssql on 
> decimal columns....
> 
> PS: I can't change the database structure so I can't change the column data 
> type at the sqlserver level and I'm in a 'read only'  context, I don't need 
> to write in the database.

Yeah this is known limitations of current pymssql and is mentioned in the docs: 
http://www.sqlalchemy.org/docs/dialects/mssql.html#limitations .    My 
understanding is that yet another pymssql version is in the works so you might 
want to contact them.   It's likely that it is coercing from floating point 
which introduces lossful conversion.   SQLAlchemy can only work with what the 
DBAPI returns which is not a string here.

FWIW pyodbc with MSSQL + FreeTDS produces accurate decimals in both directions. 
   It's fully unix/OSX compatible. 

-- 
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.

Reply via email to