You may use user-defined functions with sqlalchemy. First how to create a function with sqlalchemy: cmd1 = 'DROP FUNCTION IF EXISTS `dummyfunc`' cmd2 = '''create function dummyfunc () RETURNS INT DETERMINISTIC BEGIN DECLARE ret INT; SET ret = 0; RETURN ret; END''' metadata.bind.execute(cmd1) metadata.bind.execute(cmd2) Second, use the function you just created with func.function_name like: session.query(TestTable,func.dummyfunc()).first() Very simple!
The blog talks about data mining, algorithm, nosql, python ...