[sqlalchemy] Re: relationships for no-table-related Class

2010-11-17 Thread neurino
Thanks Michael, this solved most of my doubts. Greetings neurino On Nov 16, 5:51 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 16, 2010, at 4:19 AM, neurino wrote: I didn't mean mapping Root to a Table (if not necessary) is my intent, what I'd like to know is how to get the

Re: [sqlalchemy] order_by: ArgumentError

2010-11-17 Thread Enrico Morelli
On Tue, 16 Nov 2010 11:37:12 -0500 Michael Bayer mike...@zzzcomputing.com wrote: On Nov 16, 2010, at 6:16 AM, Enrico Morelli wrote: On Mon, 15 Nov 2010 15:56:06 -0500 Michael Bayer mike...@zzzcomputing.com wrote: its looking for a Column object.menus_table.c.weight instead of

[sqlalchemy] TIMEDIFF and SQLAlchemy

2010-11-17 Thread Christian Démolis
Hi, Do you know how to do this query with sqlalchemy? *SELECT Id, TIMEDIFF( End, Start) FROM plage WHERE TIMEDIFF(End,Start)=TIME('02:20:00');* In my model, Start and End are DateTime Start = Column('Start', DateTime) End = Column('End', DateTime) -- You received this message because you are

Re: [sqlalchemy] TIMEDIFF and SQLAlchemy

2010-11-17 Thread akm
Try this: from sqlalchemy import func from sqlalchemy.sql import select s = select( [Plage.Id, func.timediff(Plage.Start, Plage.Start) ], (func.timediff(Plage.Start, Plage.Start) = func.time('02:20:00')) ) Thanks, -- Abdul Kader M On Wed, Nov 17,

Re: [sqlalchemy] declarative one to many relationship with composite primary key

2010-11-17 Thread Adrien Saladin
On Wed, Nov 17, 2010 at 1:16 AM, Michael Bayer mike...@zzzcomputing.com wrote: ForeignKeyConstraint needs to go into __table_args__ when using declarative. http://www.sqlalchemy.org/docs/orm/extensions/declarative.html#table-configuration Thanks for the note. I have updated my test script to

[sqlalchemy] Encoding issue with SqlAlchemy + cxOracle

2010-11-17 Thread Guilherme Menezes
Hi, I am having an encoding issue using Python 2.6.2, SqlAlchemy 0.6.5 and cxOracle 5.0.4 to access an Oracle 11g database. I am using the NLS_LANG=.AL32UTF8 enviroment variable. My table in Oracle is correctly configured to accept Unicode. First, I compiled cxOracle without the WITH_UNICODE

Re: [sqlalchemy] declarative one to many relationship with composite primary key

2010-11-17 Thread Michael Bayer
On Nov 17, 2010, at 9:07 AM, Adrien Saladin wrote: On Wed, Nov 17, 2010 at 1:16 AM, Michael Bayer mike...@zzzcomputing.com wrote: ForeignKeyConstraint needs to go into __table_args__ when using declarative. http://www.sqlalchemy.org/docs/orm/extensions/declarative.html#table-configuration

Re: [sqlalchemy] is there a way to add methods to sqlsoup's MappedFoo classes?

2010-11-17 Thread Michael Bayer
On Nov 17, 2010, at 4:23 AM, J wrote: so i'm using sqlsoup to support a legacy db, and am thoroughly enjoying it. it was awesome setting up relationships and all that even though the underlying db schema didn't have any foreign key defines! however, i'm at a point where i'd like to add

Re: [sqlalchemy] Encoding issue with SqlAlchemy + cxOracle

2010-11-17 Thread Michael Bayer
On Nov 17, 2010, at 10:26 AM, Guilherme Menezes wrote: Hi, I am having an encoding issue using Python 2.6.2, SqlAlchemy 0.6.5 and cxOracle 5.0.4 to access an Oracle 11g database. I am using the NLS_LANG=.AL32UTF8 enviroment variable. My table in Oracle is correctly configured to accept

Re: [sqlalchemy] Encoding issue with SqlAlchemy + cxOracle

2010-11-17 Thread Guilherme Menezes
Thank you. I will report the problem to the cx_Oracle list and see what they have to say. Regards, Guilherme. On Wed, Nov 17, 2010 at 2:16 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 17, 2010, at 10:26 AM, Guilherme Menezes wrote: Hi, I am having an encoding issue using

[sqlalchemy] Removing an element from an uncascaded many-to-many

2010-11-17 Thread Joril
Hi everyone! I'm puzzled by a behaviour shown by SA 0.6.5 that 0.5.8 didn't show, and I'm wondering what I'm doing wrong.. I have a simple uncascaded many-to-many relationship, and if I try the following: 1) save a child 2) close the session 3) associate the child to a parent and save the parent

Re: [sqlalchemy] Problems when querying the database

2010-11-17 Thread Michael Bayer
On Nov 16, 2010, at 3:56 PM, Alvaro Reinoso wrote: Hi all, I have a problem when querying the database: This channel class: class Channel(rdb.Model): Represents both complex channels and trivial ones (media) rdb.metadata(metadata) rdb.tablename(channels)

Re: [sqlalchemy] declarative one to many relationship with composite primary key

2010-11-17 Thread Adrien Saladin
On Wed, Nov 17, 2010 at 4:58 PM, Michael Bayer mike...@zzzcomputing.com wrote: OK its actually a huge SQLA bug that an error isn't raised for that, which is surprising to me, so I created and resolved #1972 in r67d8f4e2fcb9.   __table_args__ is expected to be a tuple or dict, so now an error

Re: [sqlalchemy] Removing an element from an uncascaded many-to-many

2010-11-17 Thread Michael Bayer
you've turned off save-update cascade so the c object is not placed into the Session when you do the final save() of p. Fix: session.add_all(p.children) p.children = [] save(session, p) On Nov 17, 2010, at 12:38 PM, Joril wrote: from sqlalchemy import Column, String, Integer, Table,

Re: [sqlalchemy] Removing an element from an uncascaded many-to-many

2010-11-17 Thread Michael Bayer
I'll also make the comment that while the pattern you're illustrating is very unusual (cascade turned off, re-adding detached objects), the ORM is not being consistent in its treatment of non-included child items in mutated collections during flush, in that your append got flushed but the

[sqlalchemy] Re: is there a way to add methods to sqlsoup's MappedFoo classes?

2010-11-17 Thread J
hmm... but i was thinking of having specialized methods for every table/object. am i missing something from your suggestion? how would you have a base class that would somehow specialize depending on the child object? i went ahead and executed my mixin idea by attacking the db._cache dict with

Re: [sqlalchemy] Re: is there a way to add methods to sqlsoup's MappedFoo classes?

2010-11-17 Thread Michael Bayer
On Nov 17, 2010, at 4:05 PM, J wrote: hmm... but i was thinking of having specialized methods for every table/object. am i missing something from your suggestion? No, SqlSoup only offers the base class for all objects as an option. Here's a patch you can try: diff -r 67d8f4e2fcb9

[sqlalchemy] Re: is there a way to add methods to sqlsoup's MappedFoo classes?

2010-11-17 Thread J
to get this working, i had to add a line to clear the cache entry for attr if the base argument was passed in: def entity(self, attr, schema=None, base=None): if base: del self._cache[attr] # ADDED LINE try: t = self._cache[attr] except KeyError, ke: