[sqlalchemy] Convert JOIN to WHERE for old MySQLs

2007-12-12 Thread King Simon-NFHD78
Hi, I'm connecting to an ancient version of MySQL (3.23.58) that (as far as I can tell) doesn't support basic JOIN table ON condition syntax Ie. this gives a syntax error: SELECT * FROM productversions pv JOIN producttypes pt ON pv.producttype = pt.producttype Whereas this is fine:

[sqlalchemy] Re: LIMIT in queries

2007-12-12 Thread King Simon-NFHD78
Felix Schwarz wrote: Hi, after reading the docs [1] I thought that something like session.query(User).filter(User.c.id 3)[0] should work even if the filter clause does not return any rows. But - compliant with Python's behavior - SQLAlchemy raises an IndexError. (...) File

[sqlalchemy] Re: LIMIT in queries

2007-12-12 Thread Chris M
Or you could use .limit(1). I've always found that more clear than the Python indexing notation because I think of it slicing a list, not applying a limit to a query. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: Undeferring attributes off joined entities

2007-12-12 Thread Chris M
On further consideration of the interface, what about adding two new keywords to options() - mapper, and id? That way someone with a large group of options to set won't have to type the entity name and/or id on every single option. session.query(Class).options(options for main

[sqlalchemy] Re: Column defaults in MapperExtension.after_insert

2007-12-12 Thread King Simon-NFHD78
Michael Bayer wrote: On Dec 11, 2007, at 10:07 AM, King Simon-NFHD78 wrote: I assume the problem is that my date_created column isn't immediately available at the 'after_insert' stage, because it is generated in the SQL INSERT statement, but hasn't been read back from the

[sqlalchemy] Re: Confused about relations

2007-12-12 Thread Scott Graham
u.Xs is going to have exactly those X's which have u's id as their user_id attribute. the X which you appended to u.Ys[0] is from a different relationship. so yeah you have to set the user_id attribute on the X, which is entirely legal. However the legit way to do it is to just add the X

[sqlalchemy] Re: Convert JOIN to WHERE for old MySQLs

2007-12-12 Thread Michael Bayer
On Dec 12, 2007, at 9:04 AM, King Simon-NFHD78 wrote: Hi, I'm connecting to an ancient version of MySQL (3.23.58) that (as far as I can tell) doesn't support basic JOIN table ON condition syntax Ie. this gives a syntax error: SELECT * FROM productversions pv JOIN producttypes pt

[sqlalchemy] Re: Convert JOIN to WHERE for old MySQLs

2007-12-12 Thread King Simon-NFHD78
Michael Bayer wrote On Dec 12, 2007, at 9:04 AM, King Simon-NFHD78 wrote: Hi, I'm connecting to an ancient version of MySQL (3.23.58) that (as far as I can tell) doesn't support basic JOIN table ON condition syntax Ie. this gives a syntax error: SELECT * FROM

[sqlalchemy] Re: Convert JOIN to WHERE for old MySQLs

2007-12-12 Thread jason kirtland
King Simon-NFHD78 wrote: Hi, I'm connecting to an ancient version of MySQL (3.23.58) that (as far as I can tell) doesn't support basic JOIN table ON condition syntax Ie. this gives a syntax error: SELECT * FROM productversions pv JOIN producttypes pt ON pv.producttype =

[sqlalchemy] Re: alias problem with polymorphic joined table inheritance

2007-12-12 Thread Alexandre Conrad
Alexandre Conrad wrote: Here is the code I'm working on (sqlite and mysql errors at the bottom): http://rafb.net/p/HlZw3P26.html Here are the relations for clarity: client(company) -- one-to-many - site(company) client(company) -- one-to-many - channel(object) query == site - client

[sqlalchemy] Re: Undeferring attributes off joined entities

2007-12-12 Thread Michael Bayer
On Dec 12, 2007, at 10:07 AM, Chris M wrote: On further consideration of the interface, what about adding two new keywords to options() - mapper, and id? That way someone with a large group of options to set won't have to type the entity name and/or id on every single option.

[sqlalchemy] Re: Convert JOIN to WHERE for old MySQLs

2007-12-12 Thread King Simon-NFHD78
Jason kirtland wrote: King Simon-NFHD78 wrote: Hi, I'm connecting to an ancient version of MySQL (3.23.58) that (as far as I can tell) doesn't support basic JOIN table ON condition syntax Ie. this gives a syntax error: SELECT * FROM productversions pv JOIN

[sqlalchemy] Re: Convert JOIN to WHERE for old MySQLs

2007-12-12 Thread jason kirtland
King Simon-NFHD78 wrote: Jason kirtland wrote: King Simon-NFHD78 wrote: Hi, I'm connecting to an ancient version of MySQL (3.23.58) that (as far as I can tell) doesn't support basic JOIN table ON condition syntax This is in r3916. It's a simple change that can be easily monkey

[sqlalchemy] Re: save_or_update and composit Primary Keys... MSSQL / pyodbc issue ?

2007-12-12 Thread Rick Morrison
Hey Fabio, would you please post a full non-working copy with the new schema and all the PKs that you want set up? There are a few too many variants in this thread to see what's going on now. Your earlier versions didn't include 'station' as a PK, but did include 'start', while this one's the

[sqlalchemy] Re: Lazy ID Fetching/generation

2007-12-12 Thread Adam Batkin
yeah SQLAlchemy started, like Rick was getting at, with a much closer to the metal idea than that, that if you made a new object and put it in the session, youd know that it wasnt flushed yet. My experience with hibernate is identical, actually, nothing gets generated or anything in

[sqlalchemy] Re: save_or_update and composit Primary Keys... MSSQL / pyodbc issue ?

2007-12-12 Thread Smoke
I'm not on my pc right now so I can send you the non working copy only tomorrow I've tried several schemas changes to try and see if the problem always occurs or if there cases that it works, not necessary because i need all those schemas In the former table schema, as i said, i've

[sqlalchemy] Re: Lazy ID Fetching/generation

2007-12-12 Thread Michael Bayer
On Dec 12, 2007, at 4:49 PM, Adam Batkin wrote: I would think it could be an option on the Table (err, Column) itself and not a mapper option. Something like pending_flush=True (which can default to False to keep the current behavior...though that name probably isn't very good, but

[sqlalchemy] ordering_list for many to many relations

2007-12-12 Thread Fernando J. Zunino
Greetings, I've tried doing the following using ordering_list for many to many relations but it didn't work: post_table = Table('posts', metadata, Column('id', Integer, primary_key=True), Column('headline', String(255), nullable=False), Column('body', String) )

[sqlalchemy] Re: Matching a DateTime-field

2007-12-12 Thread Adam B
On Dec 11, 10:55 am, King Simon-NFHD78 [EMAIL PROTECTED] wrote: It may not matter to you, but I wouldn't have thought this would be a very efficient query, because the database is going to have to call the DATE_FORMAT function twice for every row in your table. I would have thought a more