[sqlalchemy] Building a query with if(type = purchase, value, 0)

2009-04-05 Thread Wouter van Vliet
Hi Folks, After an hour or so of browsing the net and documentations, getting increasingly frustrated and being about to just - nah, I didn't really consider throwing sqlalchemy out of my project. But still. Anyway, I'm trying to make a select-query which would send something like this to

[sqlalchemy] moving an object

2009-04-05 Thread jean-philippe dutreve
Hi all, I wonder if SA can handle this use case: An Account can contain Entries ordered by 'position' attribute. mapper(Account, table_accounts, properties = dict( entries = relation(Entry, lazy=True, collection_class=ordering_list ('position'), order_by=[table_entries.c.position],

[sqlalchemy] Re: Building a query with if(type = purchase, value, 0)

2009-04-05 Thread Wouter van Vliet
Thanks for your suggestion, but no such luck. From the sql error I get I gathered that that just creates an actual if_ function.. On Apr 5, 9:08 pm, a...@svilendobrev.com wrote: try with func.if_() On Sunday 05 April 2009 21:19:29 Wouter van Vliet wrote: Hi Folks, After an hour or

[sqlalchemy] Re: session close - whatfor?

2009-04-05 Thread Diez B. Roggisch
Michael Bayer schrieb: the close() will remove any objects left in the session and may help with unit tests in that the subsequent tests aren't interfered with by objects remaining from the previous test. Where is the difference between a process running several tests and one answering

[sqlalchemy] Re: moving an object

2009-04-05 Thread jason kirtland
jean-philippe dutreve wrote: Hi all, I wonder if SA can handle this use case: An Account can contain Entries ordered by 'position' attribute. mapper(Account, table_accounts, properties = dict( entries = relation(Entry, lazy=True, collection_class=ordering_list ('position'),

[sqlalchemy] Re: Building a query with if(type = purchase, value, 0)

2009-04-05 Thread Wouter van Vliet
And then I realised that I was barking up the wrong tree. Too used to mysql's if(cond,true_val,else_val) syntax I didn't even check if postgressql even know the same thing. Newsflash; it doesn't. Instead, it has the 'case' expression. To be found in the sqlalchemy.sql.expressions module. On Apr

[sqlalchemy] SA and python 26

2009-04-05 Thread Michael Mileusnich
I have been working with Python 2.5 and SQLAlchemy. I recently upgraded to Python 2.6 on my Windows machine and I receive the following message: D:\Python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\databases\ms sql.py:977: DeprecationWarning: object.__new__() takes no parameters

[sqlalchemy] Re: Building a query with if(type = purchase, value, 0)

2009-04-05 Thread Michael Bayer
i think you're looking for CASE. We have a case() construct which creates this. On Apr 5, 2009, at 3:03 PM, Wouter van Vliet wrote: Thanks for your suggestion, but no such luck. From the sql error I get I gathered that that just creates an actual if_ function.. On Apr 5, 9:08 pm,

[sqlalchemy] Re: SA and python 26

2009-04-05 Thread Michael Bayer
this is not an error, it is only a warning.There should be no difference in behavior between py2.5 and 2.6. The code you have below may not necessarily create any data if you didn't commit your transaction. On Apr 5, 2009, at 6:05 PM, Michael Mileusnich wrote: I have been working

[sqlalchemy] Re: session close - whatfor?

2009-04-05 Thread Michael Bayer
On Apr 5, 2009, at 3:34 PM, Diez B. Roggisch wrote: Michael Bayer schrieb: the close() will remove any objects left in the session and may help with unit tests in that the subsequent tests aren't interfered with by objects remaining from the previous test. Where is the difference

[sqlalchemy] Re: SA and python 26

2009-04-05 Thread Michael Mileusnich
The code used to work in 2.5. A simple add and flush was all I needed to do. I tried to use a commit but that did not work either. Am I missing something here? On Sun, Apr 5, 2009 at 4:58 PM, Michael Bayer mike...@zzzcomputing.comwrote: this is not an error, it is only a warning.There

[sqlalchemy] Re: SA and python 26

2009-04-05 Thread Michael Bayer
youd have to provide us a test case. to my knowledge our tests pass with MS on python 2.6. On Apr 5, 2009, at 7:59 PM, Michael Mileusnich wrote: The code used to work in 2.5. A simple add and flush was all I needed to do. I tried to use a commit but that did not work either. Am I

[sqlalchemy] Re: SA and python 26

2009-04-05 Thread Michael Bayer
and i would also suggest investigating if the DBAPI you're using is somehow different than the one you've used with 2.5, or unsupported on py2.6. On Apr 5, 2009, at 7:59 PM, Michael Mileusnich wrote: The code used to work in 2.5. A simple add and flush was all I needed to do. I tried

[sqlalchemy] Re: SA and python 26

2009-04-05 Thread Michael Trier
On Sun, Apr 5, 2009 at 9:46 PM, Michael Bayer mike...@zzzcomputing.comwrote: and i would also suggest investigating if the DBAPI you're using is somehow different than the one you've used with 2.5, or unsupported on py2.6. On Apr 5, 2009, at 7:59 PM, Michael Mileusnich wrote: The code used

[sqlalchemy] Re: SA and python 26

2009-04-05 Thread Michael Mileusnich
I tried to the same py scripts with sqllite and that works fine. The issues seems to be with pyodbc however I am using the version from the site. http://code.google.com/p/pyodbc/downloads/detail?name=pyodbc-2.1.3.win32-py2.6.execan=2q= My db.py file has all my tables and mappers in it and the