Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-07 Thread Matt Phipps
Sounds great; I agree avoiding the naming convention is ideal. For my project the only reason we're using a text clause is to call a stored procedure, which definitely can't go in a subquery, so I'm not sure how well I can weigh in on the aliasing stuff. -Matt On Fri, Feb 7, 2014 at 1:43 PM, Mic

Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-07 Thread Michael Bayer
On Feb 7, 2014, at 1:00 PM, Matt Phipps wrote: > > I wrote one more test that failed (but I'm pretty sure it doesn't matter): I > was under the impression that passing Label objects to .columns() would allow > you to map arbitrary result set column names to ORM attributes, and that > seems t

Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-07 Thread Matt Phipps
On Wed, Feb 5, 2014 at 7:28 PM, Michael Bayer wrote: > > OK great, added some more rules in 5c188f6c1ce85eaace27f052. > Awesome, thanks! My tests all passed on my end. As far as “names line up with the result set names”, I’m not sure what you > mean there, the .columns() method is always matchin

Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-05 Thread Michael Bayer
On Feb 5, 2014, at 6:32 PM, Matt Phipps wrote: > I've been investigating this a little further and think I found some other > issues. Our data team changed the stored procedure to stop aliasing the > column names, so passing the mapped columns right into .columns() is working > (in other word

Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-05 Thread Matt Phipps
I've been investigating this a little further and think I found some other issues. Our data team changed the stored procedure to stop aliasing the column names, so passing the mapped columns right into .columns() is working (in other words, the rest of this post doesn't reflect my use case anymore

Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-02 Thread Michael Bayer
On Feb 2, 2014, at 4:31 PM, Matt Phipps wrote: > def _trackable_truckload_details(): > text = db.text("EXEC ODSQuery.SelectBridgeLoadBoard") > cols = [col for col in LoadBoard.__table__.c] > cols = map((lambda x: label('ODSQuery_tblLoadBoard_' + x.name, x)), cols) > mobile_cols =

Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-02 Thread Matt Phipps
On Sun, Feb 2, 2014 at 11:00 AM, Michael Bayer wrote: > > So besides the “use_labels” part, the other thing that can make it work in > 0.9.1 is to link the statement to the mapped Column objects themselves: > > from sqlalchemy.sql.selectable import TextAsFrom > TextAsFrom.use_label

Re: [sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-02 Thread Michael Bayer
On Feb 2, 2014, at 12:08 AM, Matthew Phipps wrote: > > db.session.commit() > typemap = {'id': db.Integer, 'username': db.String, 'email': db.String, > 'random_time': UTCDateTime} > taf = text.columns(**typemap) > users = db.session.query(User).from_statement(taf).all() > > This results in a s

[sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-01 Thread Matthew Phipps
Hi SQLAlchemy, Our data team wants us to use a (SQL Server 2008 R2) stored procedure to perform our major query, which is all well and good, except it's preventing SQLAlchemy's type processing from being applied. This is on SQLAlchemy 0.9.1, using pyodbc and FreeTDS. For example, say we are tr