[sqlalchemy] Create a list out of multiple columns

2010-10-05 Thread Richard Poettler
Hi, I got no idea, whether this is possible with SA (version 0.6.4), but I want to map multiple columns as one list into the resulting object. I have the following code: location_table = Table('loc_location', metadata, Column('LOC_ID', Integer, primary_key=True), Column('LOC_L1',

Re: [sqlalchemy] Batch Delete with ORM

2010-10-05 Thread Chris Withers
On 04/10/2010 13:16, Mark Erbaugh wrote: If I were doing this in SQL, I would to the first command as SELECT count(*) FROM period WHERE period.cycle = ? Why would you do this first? Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Simple Join failing

2010-10-05 Thread Warwick Prince
Hi All I have what I hope is a very simple question; Just started experimenting with joins, so I tried a very basic test and got a fail that I don't understand. It appears that SA is creating bad SQL, but I'm sure it's something I'm missing.. Here's what I did; I have two tables. products

Re: [sqlalchemy] MySQL DATE_ADD function

2010-10-05 Thread Chris Withers
On 04/10/2010 22:53, Bryan wrote: I'm having trouble converting this SQL into an ORM statement. DATE_ADD(datecol, INTERVAL(1 - DAYOFWEEK(datecol)) DAY) This is as far as I can get, which is basically nowhere. The second argument to date_add requires literal strings INTERVAL and DAY, but I

Re: [sqlalchemy] Batch Delete with ORM

2010-10-05 Thread Warwick Prince
Hi All Just my 2c; The original question was why is SA doing the select before it does the delete? and then the comment was added that he would have done a simple count instead.. It appears that he was not aware that the DELETE could return the count as well (indirectly) so in actual fact,

RE: [sqlalchemy] Simple Join failing

2010-10-05 Thread King Simon-NFHD78
Warwick Prince wrote: Hi All I have what I hope is a very simple question; Just started experimenting with joins, so I tried a very basic test and got a fail that I don't understand. It appears that SA is creating bad SQL, but I'm sure it's something I'm missing.. Here's what I did;

Re: [sqlalchemy] Simple Join failing

2010-10-05 Thread Warwick Prince
Hi Simon Thanks for that - I knew it was something wrong with the approach but simply could not pick it!Back to the test bench for another go :-) Cheers Warwick P.S. OK - I have to ask - when and how (why?) do I do the .join on the query? ;-) On 5 October 2010 19:41, King Simon-NFHD78

RE: [sqlalchemy] Simple Join failing

2010-10-05 Thread King Simon-NFHD78
Warwick Prince wrote: Hi Simon Thanks for that - I knew it was something wrong with the approach but simply could not pick it!Back to the test bench for another go :-) Cheers Warwick P.S. OK - I have to ask - when and how (why?) do I do the .join on the query? ;-) In SQL,

Re: [sqlalchemy] Simple Join failing

2010-10-05 Thread Warwick Prince
Hi Simon Thanks for your help. It's amazing what a tiny hint in the right direction can do.. Between these emails, I've made a proof on concept, and am now implementing the code in the real app. So easy when I'm not blocked by a warped vision of what I'm doing. Funny, looking back at the

[sqlalchemy] eager/joined loading a whole graph

2010-10-05 Thread Peter Waller
Hi All, I have also created a post for this question on StackOverflow: http://stackoverflow.com/questions/3863508/joinedload-eager-loading-whole-sub-graphs-in-sqlalchemy Let's say I have a Task object which can be dependent on other Tasks. Is there a way to sensibly eager/joinedload all of a

Re: [sqlalchemy] Batch Delete with ORM

2010-10-05 Thread Mark Erbaugh
On Oct 5, 2010, at 4:48 AM, Chris Withers wrote: On 04/10/2010 13:16, Mark Erbaugh wrote: If I were doing this in SQL, I would to the first command as SELECT count(*) FROM period WHERE period.cycle = ? Why would you do this first? I wasn't sure why SA was issuing a select realperiod

[sqlalchemy] Re: eager/joined loading a whole graph

2010-10-05 Thread Peter Waller
Ah. To answer my own question, what I was actually after was an adjacency list, of which there are examples to be found here, which I missed: http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships I believe this will do what I was after. Sorry for the noise, and thanks

Re: [sqlalchemy] MySQL DATE_ADD function

2010-10-05 Thread Bryan Vicknair
On Tue, Oct 5, 2010 at 1:58 AM, Chris Withers ch...@simplistix.co.uk wrote: Are you looking for something database agnostic or something that just works for MySQL? If the latter, look at text: http://www.sqlalchemy.org/docs/core/tutorial.html#using-text If the former, then you'll want a

[sqlalchemy] bug with declarative's _decl_class_registry

2010-10-05 Thread Chris Withers
Hi All, Start off with a base.py module: from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() Now, say we have a module, a.py: from sqlalchemy import * from base import Base class Something(Base): __tablename__ = 'foo' id = Column('id', Integer,

Re: [sqlalchemy] bug with declarative's _decl_class_registry

2010-10-05 Thread Michael Bayer
On Oct 5, 2010, at 11:04 AM, Chris Withers wrote: Hi All, Start off with a base.py module: from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() Now, say we have a module, a.py: from sqlalchemy import * from base import Base class Something(Base):

[sqlalchemy] Re: MySQL DATE_ADD function

2010-10-05 Thread Sven A. Schmidt
Hi Bryan, the only tricky bit in your SQL is the dangling 'DAY', because there's no operator to tie it to the rest. Otherwise you should be able to write (schema.AppDcRpe2 is just a Table object I'm using as an example): q =

Re: [sqlalchemy] bug with declarative's _decl_class_registry

2010-10-05 Thread Chris Withers
On 05/10/2010 16:10, Michael Bayer wrote: I think an exception should be raised if a class name already exists in _decl_class_registry when the assignment is made in _as_declarative. yeah definitely, though in 0.6 it needs to be a warning to start since some folks might be doing this

[sqlalchemy] Re: MySQL DATE_ADD function

2010-10-05 Thread Bryan
On Oct 5, 4:45 pm, Bryan Vicknair bryanv...@gmail.com wrote: I'm fine with a MySQL-only solution. The text construct is always the fallback, but I'm wondering if there is a way that I can use the attributes of my class for the column name, instead of just a string. My column names

Re: [sqlalchemy] bug with declarative's _decl_class_registry

2010-10-05 Thread Michael Bayer
On Oct 5, 2010, at 12:37 PM, Chris Withers wrote: On 05/10/2010 16:10, Michael Bayer wrote: I think an exception should be raised if a class name already exists in _decl_class_registry when the assignment is made in _as_declarative. yeah definitely, though in 0.6 it needs to be a warning

[sqlalchemy] NUMERIC in sqlite

2010-10-05 Thread csingley
Hi, I'm just learning to use sqlalchemy now (although I've had some exposure to SQLObject and Django ORM, so not completely new to the game). I'd like to address a standard ORM issue - i.e. interfacing Python Decimal objects with SQLite backend. It seems that sqlalchemy follows the standard