[sqlalchemy] Where to use and vs and_()

2016-02-16 Thread Krishnakant
Hello all, The subject might have made my problem already clear. So I am unclear about when I should use the normal Python "and " vs the sqlalchemy "and_" while writing where, having or similar queries including joins. I have tryed understanding this but may be I have overlooked some thing.

Re: [sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Mike Bayer
On 02/16/2016 04:02 PM, Alex Hall wrote: Great; I was hoping you wouldn't say that. :) I've been through them many, many times, trying to get the connection working. I've gone from error to error, and thought I had it all working when I finally got the create_engine line to run with no

Re: [sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Alex Hall
Great; I was hoping you wouldn't say that. :) I've been through them many, many times, trying to get the connection working. I've gone from error to error, and thought I had it all working when I finally got the create_engine line to run with no problem. Apparently I'm not as far along as I

Re: [sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Mike Bayer
well then you're just not making any database connection. you'd need to check your database connectivity and your connection parameters. On 02/16/2016 03:37 PM, Alex Hall wrote: I tried that, hoping for a bit more insight into the problem. However, unless I'm doing something wrong, I don't

Re: [sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Alex Hall
I tried that, hoping for a bit more insight into the problem. However, unless I'm doing something wrong, I don't even get any queries. I get my own print statements, then the script tries to connect and hangs. I've added dbEngine.connect() just to be sure the problem is that first connection, and

Re: [sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Mike Bayer
turning on echo=True inside create_engine() will show you what queries are emitted as they occur so you can see which ones are taking long and/or hanging. On 02/16/2016 02:59 PM, Alex Hall wrote: Upon re-reading some of the docs, I realized that my problem may still be that initial

Re: [sqlalchemy] How to correctly merge objects of type X or any subclass of type X into the session?

2016-02-16 Thread Mike Bayer
On 02/16/2016 11:42 AM, Michael Naber wrote: That's interesting. So, if I'm trying to move instances between threads, is it recommended that I pass between threads the instance id, and then in the receiving thread use session.query(Person).get(instance_id), or... should I pass the instance

[sqlalchemy] Re: reflection taking a very long time?

2016-02-16 Thread Alex Hall
Upon re-reading some of the docs, I realized that my problem may still be that initial connection. The create-engine doesn't actually *connect* to the database, it just sets things up. That means that my actual connection happens later, when I try to reflect or use automap. When that happens, the

[sqlalchemy] reflection taking a very long time?

2016-02-16 Thread Alex Hall
Hi list, Sorry for all the emails. I've determined that my script is actually connecting to the 400's test database. At least, a print statement placed just after the create_engine call is printing, so I guess we're good there. What I'm running into now is unresponsiveness when I try to reflect

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-16 Thread Alex Hall
You're onto something, I think. When I use a connection string of "ibm_db_sa://user:pwd@AS400IP:DBAccessPort/DBName" I get no errors. I don't actually get anything, though; my command prompt is unresponsive, as though waiting for a script to finish, but that's all. This seems to be the 400,

Re: [sqlalchemy] How to correctly merge objects of type X or any subclass of type X into the session?

2016-02-16 Thread Michael Naber
That's interesting. So, if I'm trying to move instances between threads, is it recommended that I pass between threads the instance id, and then in the receiving thread use session.query(Person).get(instance_id), or... should I pass the instance itself (not by ID), and then use

Re: [sqlalchemy] How to correctly merge objects of type X or any subclass of type X into the session?

2016-02-16 Thread Mike Bayer
answered On 02/16/2016 09:08 AM, Michael Naber wrote: I would like to write code which can correctly merge objects of type X or any subclass of type X into the session. I have been doing session.merge(X(id=??)), which works fine for merging type X, but if the object ID references an instance

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-16 Thread Michal Petrucha
On Tue, Feb 16, 2016 at 10:27:40AM -0500, Alex Hall wrote: > I have pyodbc 3.0.10, ibm_db_sa 0.3.2, and ibm_db 2.0.6. I'm also > talking to people on the ibm_db list, and they suggested I re-install > ibm_db and ibm_db_sa according to the official tutorial, which uses > easy_install. I did so, but

Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-16 Thread Alex Hall
I have pyodbc 3.0.10, ibm_db_sa 0.3.2, and ibm_db 2.0.6. I'm also talking to people on the ibm_db list, and they suggested I re-install ibm_db and ibm_db_sa according to the official tutorial, which uses easy_install. I did so, but there was no change. As to pyodbc, I'm fine with not using it.

[sqlalchemy] Re: proper attribute names for many-to-many relationships using automap

2016-02-16 Thread Brian Cherinka
Yeah I realized I have somewhat nuanced relationships for automap to handle, and that in all the time I spent trying to figure out how to get automap working for me, I could have written my classes in explicit declarative base. So that's what I ended up doing. I was hoping to bypass that a

[sqlalchemy] How to correctly merge objects of type X or any subclass of type X into the session?

2016-02-16 Thread Michael Naber
I would like to write code which can correctly merge objects of type X or any subclass of type X into the session. I have been doing session.merge(X(id=??)), which works fine for merging type X, but if the object ID references an instance of any subclass of X, the merge results in the