On Jul 20, 4:55 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Jul 20, 2010, at 5:10 PM, Lukasz Szybalski wrote: > > > > > > > On Jul 20, 3:46 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > >> On Jul 20, 2010, at 4:44 PM, Lukasz Szybalski wrote: > > >>>> Session.execute() accepts strings that are converted to text(): > > >>>> a=session.execute("assp_ReportDailyTransactions > >>>> @start_date=:start,@end_date=:end", > >>>> params={'start':"20100701",'end':"20100719"}) > > >>> Thanks, > >>> That does work. > > >>> Is it possible to get each record to be returned as object instead of > >>> dictionary or change it so that it is similar object > >>> as ..session.query(....).all()? > > >> sure, query.from_statement(), its in the ORM tutorial.... > > > Sorry, I think I'm reading it wrong. > > > a=session.query().from_statement("assp_ReportDailyTransactions > > @start_date=:start, > > @end_date=:end").params(start="20100701",end="20100719").all() > > query() needs to have entities. Here's an example: > > http://www.sqlalchemy.org/docs/ormtutorial.html#using-literal-sql >
Can I pass in a list or some other type, I have over 30 columns? a=session.execute("assp_ReportDailyTransactions @start_date=:start, @end_date=:end",params={'start':"20100701",'end':"20100719"}) b=session.query(a.keys()).from_statement("exec assp_ReportDailyTransactions @start_date=:start, @end_date=:end").params({'start':"20100701",'end':"20100719"}).all() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/lucas/tmp/sql2008/env/lib/python2.5/site-packages/ SQLAlchemy-0.6.3-py2.5.egg/sqlalchemy/orm/session.py", line 873, in query return self._query_cls(entities, self, **kwargs) File "/home/lucas/tmp/sql2008/env/lib/python2.5/site-packages/ SQLAlchemy-0.6.3-py2.5.egg/sqlalchemy/orm/query.py", line 92, in __init__ self._set_entities(entities) File "/home/lucas/tmp/sql2008/env/lib/python2.5/site-packages/ SQLAlchemy-0.6.3-py2.5.egg/sqlalchemy/orm/query.py", line 99, in _set_entities entity_wrapper(self, ent) File "/home/lucas/tmp/sql2008/env/lib/python2.5/site-packages/ SQLAlchemy-0.6.3-py2.5.egg/sqlalchemy/orm/query.py", line 2584, in __init__ "expected - got '%r'" % column sqlalchemy.exc.InvalidRequestError: SQL expression, column, or mapped entity expected - got '[u'customer', u'customer_id', u'customer_num', u'TransactionDate'......] Thanks, Lucas -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.