Simple problem with SQLite and Standard Deviation

1,109 views
Skip to first unread message

Massi

unread,
Mar 28, 2011, 7:51:11 AM3/28/11
to sqlalchemy
Hi everyone, I'm using sqlalchemy 0.6.6 with SQLite...my problem is
simple, is there a way to compute standard deviation in sqlalchemy
with SQlite as a backend? I googled and found that native SQLite does
not support any aggregate function like MySQL 'stdev', but there exist
some extensions which could make it available. Does sqlalchemy support
something similar? Or can anyone point me out some (even ugly) hack to
work around the problem?
Thanks in advance!

Michael Bayer

unread,
Mar 28, 2011, 10:39:38 AM3/28/11
to sqlal...@googlegroups.com
you'd want to hook this in using a Python standard deviation function with sqlite3's create_aggregate():

http://docs.python.org/library/sqlite3.html#sqlite3.Connection.create_aggregate

SQLAlchemy can pass you the connection when first created via poollistener:

http://www.sqlalchemy.org/docs/core/interfaces.html?highlight=poollistener#sqlalchemy.interfaces.PoolListener

Then call any function with SQLA using "func.<name>". func.my_standard_deviation_function(xyz)

> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>

Reply all
Reply to author
Forward
0 new messages