Re: [sqlalchemy] check for None with == , within join, raises argument error

2018-02-05 Thread Jonathan Vanasco
On Monday, February 5, 2018 at 3:19:40 AM UTC-5, Rajesh Rolo wrote: > > > Thank you. .op() seems to have done the trick. I'm going to go with it as > of now. > >> Please make a test-case of your mistake though, it's important to get this figured out and patched if there is a bug. --

Re: [sqlalchemy] Discriminator on association

2018-02-05 Thread Mike Bayer
On Mon, Feb 5, 2018 at 8:40 AM, Edu Ferreira wrote: > Hello, i implemented a generic foreign key/relationship, using this example: > http://docs.sqlalchemy.org/en/latest/_modules/examples/generic_associations/discriminator_on_association.html > > In the example addresses is

[sqlalchemy] Re: contains_eager with two relationships on same table

2018-02-05 Thread Mikhail Knyazev
Ah, that makes sense! Joining with right conditions did the trick: viewed_by_user, edited_by_user = aliased(User), aliased(User) query = (session.query(News) .outerjoin(NewsLog, and_(NewsLog.news_id == News.id, or_(NewsLog.type_id == 1, NewsLog.type_id

Re: [sqlalchemy] contains_eager with two relationships on same table

2018-02-05 Thread Mike Bayer
On Mon, Feb 5, 2018 at 8:50 AM, Mikhail Knyazev wrote: > Hi, > > I got a model which has two relationships with same table through a > secondary table. Relationships are differentiated by a value of a column in > secondary table. Here is an example: > > class NewsLog: >

Re: [sqlalchemy] Session and context manager

2018-02-05 Thread Mike Bayer
On Mon, Feb 5, 2018 at 8:15 AM, Jacek Blocki wrote: > Mike, > Thank you for for the tip on _sessions, I think it is worth publishing since > it can make debugging easier. Regarding documentation it will be good to > mention session close() is not like file close() and closed

[sqlalchemy] contains_eager with two relationships on same table

2018-02-05 Thread Mikhail Knyazev
Hi, I got a model which has two relationships with same table through a secondary table. Relationships are differentiated by a value of a column in secondary table. Here is an example: class NewsLog: # `User` foreign key user_id = db.Column(db.Integer) # 'News' foreign key

[sqlalchemy] Discriminator on association

2018-02-05 Thread Edu Ferreira
Hello, i implemented a generic foreign key/relationship, using this example: http://docs.sqlalchemy.org/en/latest/_modules/examples/generic_associations/discriminator_on_association.html In the example addresses is passing in constructor: session.add_all([ Customer( name='customer

Re: [sqlalchemy] Session and context manager

2018-02-05 Thread Jacek Blocki
Mike, Thank you for for the tip on _sessions, I think it is worth publishing since it can make debugging easier. Regarding documentation it will be good to mention session close() is not like file close() and closed session is just ready for another transaction. Context manager is typically

Re: [sqlalchemy] still unclear how to invoke stored procedures with sqlalchemy

2018-02-05 Thread Mike Bayer
SQL server may require the use of cursor.callproc() to execute a stores procedure, see the documentation section on "raw cursor access" for that. In that case you are better off just executing the textual SQL directly. Though if the function works inside of a SELECT then sure the same use as with

Re: [sqlalchemy] still unclear how to invoke stored procedures with sqlalchemy

2018-02-05 Thread naufal . sarghini
What if you wanted to execute a Stored Procedure but from SQL Server instead of PostgreSQL? Will the same logic work? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable

Re: [sqlalchemy] check for None with == , within join, raises argument error

2018-02-05 Thread Rajesh Rolo
Jonathan, Thank you. .op() seems to have done the trick. I'm going to go with it as of now. Thanx, Rajesh On Monday, February 5, 2018 at 2:55:50 AM UTC+5:30, Jonathan Vanasco wrote: > > > > On Sunday, February 4, 2018 at 11:07:49 AM UTC-5, Mike Bayer wrote: >> >> You test for NULL with ==