I use this:
def CallStoredProc(conn, procName, *args): sql = """DECLARE @ret int EXEC @ret = %s %s SELECT @ret""" % (procName, ','.join(['?'] * len(args))) return int(conn.execute(sql, args).fetchone()[0])
It works only on SQL Server (or maybe Sybase), but it is a decent solution.
source share