[sqlalchemy] Re: the return type of conn.execute(text(""))

2009-01-27 Thread Faheem Mitha
[This message has also been posted.] On Wed, 28 Jan 2009 01:28:31 +0200, a...@svilendobrev.com wrote: > i have recently stumbled on similar - the rowproxy's __hash__ was > missing. so i have to tuple() them before usage. Then there was > Mike's question, what should the RowProxy emulate? the t

[sqlalchemy] Re: the return type of conn.execute(text(""))

2009-01-27 Thread Michael Bayer
On Jan 27, 2009, at 6:28 PM, a...@svilendobrev.com wrote: > > i have recently stumbled on similar - the rowproxy's __hash__ was > missing. so i have to tuple() them before usage. that doesnt strike me as a similar issue. we should apply that patch someone had to detect python < 2.6 and plac

[sqlalchemy] Re: the return type of conn.execute(text(""))

2009-01-27 Thread az
On Wednesday 28 January 2009 01:34:30 Michael Bayer wrote: > On Jan 27, 2009, at 6:28 PM, a...@svilendobrev.com wrote: > > i have recently stumbled on similar - the rowproxy's __hash__ was > > missing. so i have to tuple() them before usage. > > that doesnt strike me as a similar issue. we shoul

[sqlalchemy] Re: and_ and or_ precedence

2009-01-27 Thread az
theoretically - this might make a+b+c+d look like a+(b+(c+d)). Which isn't that bad, except that SA does not level-indent parenthesised expressions, and the sql is going to look like lisp program... but yes, u're right, SA relies on some python precedence and associativity being same as SQL on

[sqlalchemy] Re: and_ and or_ precedence

2009-01-27 Thread Michael Bayer
On Jan 27, 2009, at 6:14 PM, Jon Nelson wrote: > > I recently ran into an issue. Is it a bug? No. However, it made my > brain hurt for a little bit until I remembered the SQL precedence > rules for AND and OR. > > The operator precedence of AND and OR is known (AND takes precedence). > However,

[sqlalchemy] Re: Best way to count( some_relation )

2009-01-27 Thread Michael Bayer
it still is needed if you explicitly need an alias() of your SELECT statement. joining to it, embedding it within aliased().haven't figured out yet if there's some way to make it "automatic" in all cases or if thats appropriate. also more controverially im thinking of adding a .c. to Q

[sqlalchemy] Re: the return type of conn.execute(text(""))

2009-01-27 Thread az
i have recently stumbled on similar - the rowproxy's __hash__ was missing. so i have to tuple() them before usage. Then there was Mike's question, what should the RowProxy emulate? the tuple of the row, or something else? > Today I attempted to serialize the return value of the form > > result =

[sqlalchemy] and_ and or_ precedence

2009-01-27 Thread Jon Nelson
I recently ran into an issue. Is it a bug? No. However, it made my brain hurt for a little bit until I remembered the SQL precedence rules for AND and OR. The operator precedence of AND and OR is known (AND takes precedence). However, it can make humans hurt their brains a bit to see SQL without

[sqlalchemy] the return type of conn.execute(text(""))

2009-01-27 Thread Faheem Mitha
Hi, Today I attempted to serialize the return value of the form result = conn.execute(text("")) Till now I thought that the return type was a list of tuples, while in fact it is a list of objects of type . Hence cPickle refused to serialize till I did some conversion. Just wondering what th

[sqlalchemy] Re: Best way to count( some_relation )

2009-01-27 Thread Jon Nelson
> im committing something that will make that exact phrase work (its in > rev 5734). using a released version of SQLA, for now say > id.in_(query.statement). I took at look at those changes and they look awesome! If I understand the changes correctly, however, then I wonder what purpose subquer

[sqlalchemy] Re: Creating Tables From Selects

2009-01-27 Thread MikeCo
I found this to be an interesting little problem. The task can be accomplished by using the text of a statement to construct a new string then executing. Here is a simple recipe using SQLite. I'm sure it can be extended fairly easily, and should work in any standard SQL environment import sqlal

[sqlalchemy] Re: Creating Tables From Selects

2009-01-27 Thread Roger Demetrescu
On Tue, Jan 27, 2009 at 14:31, Michael Bayer wrote: > > there's nothing stopping you from just executing the SQL directly. > I've never actually heard of CREATE TABLE AS before, but I just > checked it out and you can certainly generate the SQL programmatically > from a select, by inspecting each

[sqlalchemy] Re: implicit vs explicit join

2009-01-27 Thread Michael Bayer
On Jan 27, 2009, at 10:14 AM, Jon Nelson wrote: > > My understanding is that some databases prefer the explicit JOIN > syntax from an optimization POV, and of course the explicit JOIN > syntax is ANSI SQL. Googlin' suggests that the ANSI syntax is > preferred (perhaps even required) by some engi

[sqlalchemy] Re: Creating Tables From Selects

2009-01-27 Thread Michael Bayer
there's nothing stopping you from just executing the SQL directly. I've never actually heard of CREATE TABLE AS before, but I just checked it out and you can certainly generate the SQL programmatically from a select, by inspecting each column in the select statement's "c" collection.

[sqlalchemy] Creating Tables From Selects

2009-01-27 Thread andrew cooke
(I thought this might be a FAQ, but I can't find it, and searching isn't turning up anything either...). Am I right n thinking it is not possible to do "CREATE TABLE AS" in SQLAlchemy? In other words, creating a table from a select statement? I'm using 0.4 and Oracle. If it is possible I

[sqlalchemy] implicit vs explicit join

2009-01-27 Thread Jon Nelson
I have a question about implicit vs explicit joins in SA. I have three tables with an odd relationship (legacy DB issues). Assume tables 'accounts' and 'account_config' and a secondary table 'account_to_config'. The true nature of the relation is 1:1, however (again, it's an inherited schema...)

[sqlalchemy] Re: Mixing synonyms and properties with reflected tables..

2009-01-27 Thread Toby Bradshaw
Thanks very much for that detailed explanation which has proved very helpful. In the end it turns out that the particular construct I need is the simple: mapper(MyClass, table, properties={ "timeunits": synonym("time_units") }) coupled with a data-descriptor for 'timeunits' on the object

[sqlalchemy] get a SQL Query out of my SA mappings, possible?

2009-01-27 Thread Nahuel Defossé
I'm developing a small twisted/pyqt/sqlalchemy application (data acquisition soft and control). I have a GUI where I have to show some data from my beautiful SA model. This gui is built on PyQt. PyQt has a nice set of data access classes, but they use _raw_ SQL, that's OK for most people using

[sqlalchemy] find only loaded objects in relation collections

2009-01-27 Thread GHZ
Hi, I have a Subscriber and an Address table. Subscriber can have many Addresses mapper(Subscriber, subscriber_table, properties={ 'addresses' : relation(Address, collection_class=Addresses, backref='customer')}) >From the a Subscriber object, I want to inspect all loaded objects in any c

[sqlalchemy] Re: SQL Expressions as Mapped Attributes

2009-01-27 Thread Nathan Harmston
Thanks for that, I think I should have made my question a little clearer, (it works for what I was asking but not what I want it to do). spec_names = join(species_table, species_names_table, and_(species_table.c.rank=="species", species_table.c.taxa_id==species_names_table.c.taxa)) mapper(Species,

[sqlalchemy] Re: Full connection pool close

2009-01-27 Thread Smoke
On 24 Gen, 23:31, Rick Morrison wrote: > > Oh... i didn't explain myself... I mean that it's already empty at the > > first cycle of the loop... > > It would be normal to not enter the loop if you haven't yet opened any > connections, as connections are opened on demand. Make sure your program