Re: [sqlalchemy] select count(*)

2011-11-04 Thread werner
On 11/04/2011 03:11 AM, Mark Erbaugh wrote: On Nov 3, 2011, at 3:31 PM, werner wrote: Mark, On 11/03/2011 07:18 PM, Mark Erbaugh wrote: Using the query object count() method generates a sub-query (as per the docs). The docs say to use func.count to avoid the subquery. func.count seems to

Re: [sqlalchemy] select count(*)

2011-11-04 Thread Stefano Fontanelli
Il 04/11/11 03.08, Mark Erbaugh ha scritto: On Nov 3, 2011, at 2:54 PM, Stefano Fontanelli wrote: Il 03/11/11 19.18, Mark Erbaugh ha scritto: Using the query object count() method generates a sub-query (as per the docs). The docs say to use func.count to avoid the subquery. func.count seems

Re: [sqlalchemy] per-host pooling vs per-engine pooling

2011-11-04 Thread Tarek Ziadé
On Thu, Nov 3, 2011 at 11:31 PM, Michael Bayer mike...@zzzcomputing.com wrote: ... I should look at this more closely, took a brief glance.  One thought I had was why not do the switch the schema thing within Engine.connect(), at least there you know which engine you're dealing with. Ok

Re: [sqlalchemy] per-host pooling vs per-engine pooling

2011-11-04 Thread Tarek Ziadé
On Fri, Nov 4, 2011 at 10:33 AM, Tarek Ziadé ziade.ta...@gmail.com wrote: ... Will try and come back ;) Hello, I am back \o/ Here's my v2: http://tarek.pastebin.mozilla.org/1373520 This time I have created a custom Strategy and Engine classes, and the get_engine() function takes care of

Re: [sqlalchemy] select count(*)

2011-11-04 Thread Mark Erbaugh
On Nov 4, 2011, at 4:54 AM, Stefano Fontanelli wrote: Il 04/11/11 03.08, Mark Erbaugh ha scritto: On Nov 3, 2011, at 2:54 PM, Stefano Fontanelli wrote: Il 03/11/11 19.18, Mark Erbaugh ha scritto: Using the query object count() method generates a sub-query (as per the docs). The docs

[sqlalchemy] Issue with compound foreign key

2011-11-04 Thread Thijs Engels
I am having some trouble getting the code below to work... running the code below will give this error message when trying to create a Session object (last line): sqlalchemy.exc.ArgumentError: Could not determine relationship direction for primaryjoin condition

Re: [sqlalchemy] per-host pooling vs per-engine pooling

2011-11-04 Thread Michael Bayer
On Nov 4, 2011, at 3:41 AM, Tarek Ziadé wrote: On Fri, Nov 4, 2011 at 10:33 AM, Tarek Ziadé ziade.ta...@gmail.com wrote: ... Will try and come back ;) Hello, I am back \o/ Here's my v2: http://tarek.pastebin.mozilla.org/1373520 This time I have created a custom Strategy and Engine

Re: [sqlalchemy] Issue with compound foreign key

2011-11-04 Thread Michael Bayer
On Nov 4, 2011, at 3:25 AM, Thijs Engels wrote: I am having some trouble getting the code below to work... running the code below will give this error message when trying to create a Session object (last line): sqlalchemy.exc.ArgumentError: Could not determine relationship direction for

Re: [sqlalchemy] query returns a non-result?

2011-11-04 Thread Michael Bayer
On Nov 3, 2011, at 9:33 AM, Chris Withers wrote: Hi All, Any idea what this traceback is about? This query normally works fine and is run a few hundred times a day ;-) if you use the DBAPI and you say: cursor = conn.cursor() cursor.execute(UPDATE XYZ set foo=bar) if you were to then try

Re: [sqlalchemy] per-host pooling vs per-engine pooling

2011-11-04 Thread Tarek Ziadé
On Fri, Nov 4, 2011 at 4:45 PM, Michael Bayer mike...@zzzcomputing.com wrote: ... OK this is clearer to me.     So you're really trying to get it so that any number of create_engine() calls all use the same pool based on hostname, OK. If i have time today I might want to try paring this down

Re: [sqlalchemy] Foreign key reflection error?

2011-11-04 Thread thatsanicehatyouhave
Hello, Thanks Mike for the comments. Before I answer the questions you asked, I want to note I found a workaround without making any changes to the database-- I just reversed the tables in the definition. At first I was using: Survey.bossSpectrumHeaders = relationship(BOSSSpectrumHeader,

Re: [sqlalchemy] Foreign key reflection error?

2011-11-04 Thread Michael Bayer
I think the important thing here is that the table definition on the Python side needs to represent the table in the same way that the foreign key def will represent it from PG. It's based on this fact: I was reading the descriptions from PGAdmin3 - apparently they drop the schema in the

[sqlalchemy] How to get literal default column values?

2011-11-04 Thread Roger Hoover
Hi, I'm trying to use the sqlalchemy compiler to generate insert statements that I can feed myself to MySQLdb. With a sqlalchemy table definition, I'm able to get a nice SQL statement using the following. query =

[sqlalchemy] Re: How to get literal default column values?

2011-11-04 Thread Roger Hoover
I found that the following works. I'm wondering if there's a better way. def _add_insert_default_values(self, kwargs): for col in self._table.c.keys(): default = self._table.c[col].default if default is not None and default.is_scalar: if col

Re: [sqlalchemy] How to get literal default column values?

2011-11-04 Thread Michael Bayer
On Nov 4, 2011, at 3:19 PM, Roger Hoover wrote: Hi, I'm trying to use the sqlalchemy compiler to generate insert statements that I can feed myself to MySQLdb. With a sqlalchemy table definition, I'm able to get a nice SQL statement using the following. query =

Re: [sqlalchemy] How to get literal default column values?

2011-11-04 Thread Roger Hoover
On Fri, Nov 4, 2011 at 3:57 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Nov 4, 2011, at 3:19 PM, Roger Hoover wrote: Hi, I'm trying to use the sqlalchemy compiler to generate insert statements that I can feed myself to MySQLdb. With a sqlalchemy table definition, I'm able to