The MySQL console can’t show you this because “Decimal” is a Python type.   the 
way to see what is going on is to test with the MySQLdb driver directly, though 
in this case it’s easy enough to see it also with “echo=‘debug’”.


> On Nov 11, 2014, at 1:09 PM, Thomas Wanschik <[email protected]> wrote:
> 
> Thanks for your answer.
> 
> I did the exact same raw sql query (got the query string via echo=True) and 
> it seems like mysql returned an integer (console print looked like a 
> integer). So I concluded it has to be converted somewhere on the way through 
> sqlalchemy.
> 
> 
> On Tuesday, November 11, 2014 6:25:44 PM UTC+1, Thomas Wanschik wrote:
> Hi,
> the query
> 
> session.query(func.sum(MyModel.amount)).scalar()
> 
> with 
> 
> MyModel.amount = Column(SmallInteger, nullable=False)
> 
> returns a Decimal instead of an integer when using mysql with the default 
> driver (as well as with the cymysql driver).
> 
> How can I get this query to return an integer? And why can't it return an 
> integer automatically?
> 
> Thanks in advance
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/sqlalchemy 
> <http://groups.google.com/group/sqlalchemy>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to