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()

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/query.py", line 1453, in all
    return list(self)
  File "/home/lucas/tmp/sql2008/env/lib/python2.5/site-packages/
SQLAlchemy-0.6.3-py2.5.egg/sqlalchemy/orm/query.py", line 1565, in
__iter__
    return self._execute_and_instances(context)
  File "/home/lucas/tmp/sql2008/env/lib/python2.5/site-packages/
SQLAlchemy-0.6.3-py2.5.egg/sqlalchemy/orm/query.py", line 1570, in
_execute_and_instances
    mapper=self._mapper_zero_or_none())
  File "/home/lucas/tmp/sql2008/env/lib/python2.5/site-packages/
SQLAlchemy-0.6.3-py2.5.egg/sqlalchemy/orm/query.py", line 276, in
_mapper_zero_or_none
    if not getattr(self._entities[0], 'primary_entity', False):
IndexError: list index out of range

Thanks,
Lucas



>
>
> > I need to pass in the objects a[5] or do
>
> > a=session.execute("assp_ReportDailyTransactions
> > @start_date=:start,@end_date=:end",
> > params={'start':"20100701",'end':"20100719"})
> > new_record=a[5]
>
> > print new_record.customername
> > #call a function by passing the object
> > process_client(new_record)
> > #the process_client function can access records like
> > new_record.clientname,new_record.transaction_date
>
> > right now I get:
> > a[5]
> > Traceback (most recent call last):
> >  File "<stdin>", line 1, in <module>
> > TypeError: 'ResultProxy' object is unindexable
>
> > Do I convert the return or I use a different command?
>
> > 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 
> > athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
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.

Reply via email to