[sqlalchemy] Unexplainable SQL queries / Performance issues

2012-11-21 Thread Martin84
Hi, I use SQLalchemy 0.7.9 with SQLite and have a performance issue. I have a simple database with joined table inheritance and some relationships. In short: I have a base class Human, and 3 subclasses (Men, Woman and Child), and I have a class House. The house class have a many to many

Re: [sqlalchemy] SQLAlchemy transaction problem

2012-11-21 Thread Thierry Florac
Hi Michael, I applied your patch on my current SA 0.7.3 without any problem, and added a few traces. Everything seems to work perfectly! Here is the first output with updates: do_begin_twophase do_prepare_twophase = True do_commit_twophase oci_prepared = True do_commit and

Re: [sqlalchemy] Re: ObjectDeletedError: Instance 'xxx' has been deleted

2012-11-21 Thread sajuptpm
Hi, Michael Bayer. Thanks, that example is really helpful. In your example I used *Session.object_session*http://docs.sqlalchemy.org/en/latest/orm/session.html#sqlalchemy.orm.session.Session.object_sessionmethod to verify that main_method and method1 running in two different sessions. But my

Re: [sqlalchemy] Trying to apply result of raw sql to an 'in_' clause of mapped table

2012-11-21 Thread Audrius Kažukauskas
On Wed, 2012-11-21 at 13:05:22 +0100, Ralph Heinkel wrote: The latter was my favorite, but this seems to fail with [...] File /usr/local/lib/python2.7/site-packages/SQLAlchemy-0.5.8-py2.7.egg/sqlalchemy/sql/expression.py, line 1390, in in_ return self._in_impl(operators.in_op,

RE: [sqlalchemy] Inheriting a functionality in SQLA

2012-11-21 Thread Alexey Vihorev
Yes, I tried mix-in approach, and it works, thanks. From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of Robert Forkel Sent: 20 ноября 2012 г. 17:09 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Inheriting a functionality in SQLA As far as i know

Re: [sqlalchemy] Unexplainable SQL queries / Performance issues

2012-11-21 Thread Diana Clarke
Morning Martin: I could be wrong, but I think what you're looking for is lazy='joined' rather than lazy='subquery'. When I change the following, I see one query per showDatabase() call rather than two. class Men(Human): myChildren = relationship('Child', secondary=link_table,

Re: [sqlalchemy] SQLAlchemy transaction problem

2012-11-21 Thread Michael Bayer
On Nov 21, 2012, at 5:32 AM, Thierry Florac wrote: Hi Michael, I applied your patch on my current SA 0.7.3 without any problem, and added a few traces. Everything seems to work perfectly! Here is the first output with updates: do_begin_twophase do_prepare_twophase = True

Re: [sqlalchemy] Trying to apply result of raw sql to an 'in_' clause of mapped table

2012-11-21 Thread Michael Bayer
On Nov 21, 2012, at 7:05 AM, Ralph Heinkel wrote: Hi Michael, thanks for your reply. but with that aside, you can use text(): from sqlalchemy import text, bindparam Person.status_id.in_(text(select status_id ..., bindparams=[bindparam('n1', 'hired')])) and the bind values you can

Re: [sqlalchemy] Zope-SQLAlchemy extension

2012-11-21 Thread Clemens Herschel
On 11/16/2012 9:00 PM, Michael Bayer wrote: On Nov 16, 2012, at 11:40 AM, Clemens Herschel, III wrote: In a pyramid application: In models.py: DBSession= scoped_session(sessionmaker(extensions=ZopeTransactionExtension())) In view: dbsession = DBSession def add(request):

Re: [sqlalchemy] Trying to apply result of raw sql to an 'in_' clause of mapped table

2012-11-21 Thread Ralph Heinkel
The latter was my favorite, but this seems to fail with [...] File /usr/local/lib/python2.7/site-packages/SQLAlchemy-0.5.8-py2.7.egg/sqlalchemy/sql/expression.py, line 1390, in in_ return self._in_impl(operators.in_op, operators.notin_op, other) File

Re: [sqlalchemy] SQLAlchemy transaction problem

2012-11-21 Thread Michael Bayer
this will need lots more work on my end and may not be possible without major caveats. once you use connection.begin(*xid), the cx_oracle connection goes into a new mode that seems to render the usual DBAPI contract of implicit begin permanently broken. I've spent about three hours trying to

[sqlalchemy] Re: Is it possible to define multiple model objects that refer to the same table?

2012-11-21 Thread Rob Crowell
Thanks so much! Your pointers were exactly what I needed, specifically the bit which led me to discover exclude_properties. I'll leave my working code here in case it ever helps anybody else out: from sqlalchemy import Column, Date, Enum, Integer, String, Table, create_engine from

Re: [sqlalchemy] sqlalchemy.exc.DBAPIError: (Error) ('HY003', '[HY003] [FreeTDS][SQL Server]Program type out of range (0) (SQLGetData)') None None

2012-11-21 Thread Lukasz Szybalski
On Friday, November 16, 2012 7:52:00 PM UTC-6, Michael Bayer wrote: On Nov 16, 2012, at 11:44 AM, Lukasz Szybalski wrote: Hello, Any idea what this error message means. I'm trying to execute this: s=session.execute(assp_Checks @begin_date=:start,

[sqlalchemy] pymssql and uuid.UUID convertion

2012-11-21 Thread Ivan Kalinin
Hellow, fellow developers! I have run into and issue trying to use SQLAlchemy (0.7.4) and recent pymssql (2.0.0). Precisely, pymssql can not handle uuid.UUID objects as parameters (see related post on their ML herehttps://groups.google.com/forum/?fromgroups=#!topic/pymssql/ah6f8cl2Va0), but

RE: [sqlalchemy] Inheriting a functionality in SQLA

2012-11-21 Thread Alexey Vihorev
Thanks for the clarification, it works now. From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of Michael Bayer Sent: 21 ноября 2012 г. 3:58 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Inheriting a functionality in SQLA On Nov 20, 2012, at

[sqlalchemy] Detect whether a query already has a join on a table?

2012-11-21 Thread Kevin Q
I want to avoid double joining on the same table. I know query._from_obj is where the query stores the join elements. However, it's not there if the join is from query.options(joinedload('some_relation')). For example, I have the following table relations: User: * userid * name Thing *