views:

42

answers:

2

How can I call stored procedures of sql server with sqlAlchemy?

A: 

Engines and Connections have an execute() method you can use for arbitrary sql statements, and so do Sessions. For example:

results = sess.execute('myproc ?, ?', [param1, param2])

You can use outparam() to create output parameters if you need to (or for bind parameters use bindparam() with the isoutparam=True option)

Steven
A: 

Just execute procedure object created with func:

from sqlalchemy import create_engine, func
from sqlalchemy.orm import sessionmaker

engine = create_engine('sqlite://', echo=True)
print engine.execute(func.upper('abc')).scalar() # Using engine
session = sessionmaker(bind=engine)()
print session.execute(func.upper('abc')).scalar() # Using session
Denis Otkidach