Re: [sqlalchemy] Is it possible to populate relationship's collection with only query-filtered results using contains_eager()?
Well, I added echo=True and saw the queries - no additional were made. Then I added populate_existing() and out of the blue I started to get the desired result, but frankly I don't quite understand why. What side-effects this could bring? суббота, 31 января 2015 г., 21:22:08 UTC+5 пользователь Michael Bayer написал: Anyway, yes, contains_eager says, “populate these collections”. the usage looks correct, so the echo=True, or even echo=‘debug’ which will show you the result rows coming in, will show you where its going wrong. or if those collections were already populated previously within that Session, that would affect it also. you can say query.populate_existing() to force it to re-load everything. and out of the blue I started to get the desired result, but frankly I don't quite understand why суббота, 31 января 2015 г., 21:22:08 UTC+5 пользователь Michael Bayer написал: Anyway, yes, contains_eager says, “populate these collections”. the usage looks correct, so the echo=True, or even echo=‘debug’ which will show you the result rows coming in, will show you where its going wrong. or if those collections were already populated previously within that Session, that would affect it also. you can say query.populate_existing() to force it to re-load everything. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] scalar() works with outerjoin()?
Does scalar() work with outerjoin()? I have an outerjoin sql statement that will only return 1 row. I used scalar(), but then I could not get the column values of the 2nd table. I fixed it, but just wondering if scalar() and outerjoin() are not to be mixed in the same sql statement? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] scalar() works with outerjoin()?
oh, I found the function: first() which seems to work fine with joined queries. On Mon, Feb 2, 2015 at 12:21 AM, Dennis dennisf...@gmail.com wrote: Does scalar() work with outerjoin()? I have an outerjoin sql statement that will only return 1 row. I used scalar(), but then I could not get the column values of the 2nd table. I fixed it, but just wondering if scalar() and outerjoin() are not to be mixed in the same sql statement? -- You received this message because you are subscribed to a topic in the Google Groups sqlalchemy group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/si-gRQnxPWk/unsubscribe. To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] Re: How to log all SQL executed during database introspection?
On Saturday, January 31, 2015 at 7:41:15 PM UTC-5, Fabio Caritas Barrionuevo da Luz wrote: Hello, how to log all SQL executed during database introspection? I would like to understand how exactly SQLAlchemy does on introspection the database. The easiest way is to turn on ALL sql logging to the python logger. The engine accepts an `echo` param that will enable this: http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html#sqlalchemy.create_engine.params.echo if you only want to handle database introspection, you'd probably need to use the events system. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Is it possible to populate relationship's collection with only query-filtered results using contains_eager()?
Юрий Пайков dia...@cry5tal.in wrote: Well, I added echo=True and saw the queries - no additional were made. Then I added populate_existing() and out of the blue I started to get the desired result, but frankly I don't quite understand why. What side-effects this could bring? it means the parent records in question were already loaded, and already present in the identity map for your session - the collections were there already, and the contains_eager had no effect on their contents. суббота, 31 января 2015 г., 21:22:08 UTC+5 пользователь Michael Bayer написал: Anyway, yes, contains_eager says, “populate these collections”. the usage looks correct, so the echo=True, or even echo=‘debug’ which will show you the result rows coming in, will show you where its going wrong. or if those collections were already populated previously within that Session, that would affect it also. you can say query.populate_existing() to force it to re-load everything. and out of the blue I started to get the desired result, but frankly I don't quite understand why суббота, 31 января 2015 г., 21:22:08 UTC+5 пользователь Michael Bayer написал: Anyway, yes, contains_eager says, “populate these collections”. the usage looks correct, so the echo=True, or even echo=‘debug’ which will show you the result rows coming in, will show you where its going wrong. or if those collections were already populated previously within that Session, that would affect it also. you can say query.populate_existing() to force it to re-load everything. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] Is it possible in sqlalchemy to define a column which is a list of uuids
Hi, We are using postgres and sqlalchemy. But now we are having problem to define a column which is a list of uuids because sqlalchemy always converted them into a list of string. Is there a good way to resolve this? Thanks, -Weihua -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Is it possible in sqlalchemy to define a column which is a list of uuids
this is an open issue right now due to https://bitbucket.org/zzzeek/sqlalchemy/issue/2940/postgresql-array-uuid. You can work around right now by calling psycopg2’s adapter globally: import psycopg2.extras psycopg2.extras.register_uuid() or you can implement per-connection: from sqlalchemy.engine import Engine from sqlalchemy import event @event.listens_for(Engine, connect) def connect(dbapi_connection, connection_record): psycopg2.extras.register_uuid(None, dbapi_connection) Weihua Zhu zhuwh1...@gmail.com wrote: Hi, We are using postgres and sqlalchemy. But now we are having problem to define a column which is a list of uuids because sqlalchemy always converted them into a list of string. Is there a good way to resolve this? Thanks, -Weihua -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Is it possible in sqlalchemy to define a column which is a list of uuids
Michael Bayer mike...@zzzcomputing.com wrote: this is an open issue right now due to https://bitbucket.org/zzzeek/sqlalchemy/issue/2940/postgresql-array-uuid. Since someone had already provided tests, I pushed up the fix which is in master / rel_1_0 / rel_0_9 and will be in 0.9.9. You can work around right now by calling psycopg2’s adapter globally: import psycopg2.extras psycopg2.extras.register_uuid() or you can implement per-connection: from sqlalchemy.engine import Engine from sqlalchemy import event @event.listens_for(Engine, connect) def connect(dbapi_connection, connection_record): psycopg2.extras.register_uuid(None, dbapi_connection) Weihua Zhu zhuwh1...@gmail.com wrote: Hi, We are using postgres and sqlalchemy. But now we are having problem to define a column which is a list of uuids because sqlalchemy always converted them into a list of string. Is there a good way to resolve this? Thanks, -Weihua -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] One to many lazy load generates incorrect query when the parent attribute appears more than once in the join expression
I am trying to define a relationship that self-joins multiple columns on IS NOT DISTINCT FROM. Since the backend I use does not support it, I mimic it like this: - notdistinct = lambda a, b: ~((a != b) | (a == None) | (b == None)) | ((a == None) (b == None)) - rel = relationship('Table', - primaryjoin=lambda: and_(notdistinct(Table.attr, foreign(remote(Table.attr))), -# ...the same for several multiple attributes... - )) This works fine when when joining, but the lazy loading generates SQL like this: - WHERE -NOT (Table.attr != ? OR Table.attr IS NULL OR Table.attr IS NULL) OR -(Table.attr IS NULL AND Table.attr IS NULL) - Which is incorrect. Is there a way to help sqlalchemy identify where it should substitute the parent key when it appears more than once? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Is it possible to populate relationship's collection with only query-filtered results using contains_eager()?
Thanks Michael for your attention! понедельник, 2 февраля 2015 г., 2:56:51 UTC+5 пользователь Michael Bayer написал: Юрий Пайков dia...@cry5tal.in javascript: wrote: Well, I added echo=True and saw the queries - no additional were made. Then I added populate_existing() and out of the blue I started to get the desired result, but frankly I don't quite understand why. What side-effects this could bring? it means the parent records in question were already loaded, and already present in the identity map for your session - the collections were there already, and the contains_eager had no effect on their contents. суббота, 31 января 2015 г., 21:22:08 UTC+5 пользователь Michael Bayer написал: Anyway, yes, contains_eager says, “populate these collections”. the usage looks correct, so the echo=True, or even echo=‘debug’ which will show you the result rows coming in, will show you where its going wrong. or if those collections were already populated previously within that Session, that would affect it also. you can say query.populate_existing() to force it to re-load everything. and out of the blue I started to get the desired result, but frankly I don't quite understand why суббота, 31 января 2015 г., 21:22:08 UTC+5 пользователь Michael Bayer написал: Anyway, yes, contains_eager says, “populate these collections”. the usage looks correct, so the echo=True, or even echo=‘debug’ which will show you the result rows coming in, will show you where its going wrong. or if those collections were already populated previously within that Session, that would affect it also. you can say query.populate_existing() to force it to re-load everything. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com javascript:. To post to this group, send email to sqlal...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.