Re: [sqlalchemy] money type for Postgresql

2011-12-28 Thread Martijn Moeling
I use Float for money at the moment. I am moving from Mysql to Postgres and have not had any issues but i'm not sure if Float actually works correctly. Floats are being used for both broken number values and for money values. should I change to numeric for Postgres as I do not see that Column

Re: [sqlalchemy] money type for Postgresql

2011-12-28 Thread Julien Cigar
Using FLOAT for monetary amounts is an extremely bad idea because of the inexactness of storage and arithmetic .. Using MONEY is discouraged because it is too locale-sensitive NUMERIC should be used instead On 12/28/2011 11:48, Martijn Moeling wrote: I use Float for money at the moment. I am

Re: [sqlalchemy] Re: 0.7 event migration

2011-12-28 Thread Kent
On 12/27/2011 5:34 PM, Michael Bayer wrote: On Dec 27, 2011, at 5:21 PM, Kent wrote: So see what happens if you, for the moment, just monkeypatch over orm.session._state_session to do a lookup in a global context if state.session_id isn't set. If that solves the problem of I want detached

[sqlalchemy] InvalidRequestError: Can't reconnect until invalid transaction is rolled back error during SELECT query

2011-12-28 Thread Josh Ha-Nyung Chung
I've made web application using Pyramid 1.2.5 + Python 2.7.1 + SQLAlchemy 0.7.4 and occasionally encountered the following error. Traceback (most recent call last): File /usr/local/lib/python2.7/site-packages/pyramid/router.py, line 176, in __call__ response = self.handle_request(request)

[sqlalchemy] InvalidRequestError: get() can only be used against a single mapped class.

2011-12-28 Thread Kent
Was it your intention to no longer allow this type of query().get()? session.query(cls.orderid).get(orderid) I get InvalidRequestError: get() can only be used against a single mapped class. but the wording is such that I'm not sure you intended to limit that use case (there is only a single

Re: [sqlalchemy] Re: 0.7 event migration

2011-12-28 Thread Michael Bayer
On Dec 28, 2011, at 9:18 AM, Kent wrote: Off topic, but from a shell prompt I sometimes find myself naturally attempting this: session.detach(instance) and then when that fails, I remember: session.expunge(instance) I'm not asking for a change here, but quite curious: you think

Re: [sqlalchemy] InvalidRequestError: get() can only be used against a single mapped class.

2011-12-28 Thread Michael Bayer
On Dec 28, 2011, at 11:34 AM, Kent wrote: Was it your intention to no longer allow this type of query().get()? session.query(cls.orderid).get(orderid) it was ! yes. I get InvalidRequestError: get() can only be used against a single mapped class. but the wording is such that I'm not

Re: [sqlalchemy] Order by the sequence in_ ?

2011-12-28 Thread Michael Bayer
On Dec 27, 2011, at 8:37 PM, Vlad K. wrote: Hi all. I need to select some rows where pkey is in a sequence. How do I order by that very sequence? images_all = session.query(AdImage).filter(AdImage.image_id.in_(images)).order_by( ? ).all() Postgresql backend. typically

Re: [sqlalchemy] InvalidRequestError: Can't reconnect until invalid transaction is rolled back error during SELECT query

2011-12-28 Thread Michael Bayer
On Dec 27, 2011, at 11:58 PM, Josh Ha-Nyung Chung wrote: I've made web application using Pyramid 1.2.5 + Python 2.7.1 + SQLAlchemy 0.7.4 and occasionally encountered the following error. File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 1599, in _execute_context

Re: [sqlalchemy] Re: 0.7 event migration

2011-12-28 Thread Michael Hipp
On 2011-12-28 10:58 AM, Michael Bayer wrote: detach(), also nice. This seems most descriptive of what is actually taking place. I poured over the docs for some time looking for the detach() method. Michael -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: InvalidRequestError: get() can only be used against a single mapped class.

2011-12-28 Thread Kent
On Dec 28, 12:07 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 28, 2011, at 11:34 AM, Kent wrote: Was it your intention to no longer allow this type of query().get()? session.query(cls.orderid).get(orderid) it was !   yes. I get InvalidRequestError: get() can only be

[sqlalchemy] Re: InvalidRequestError: get() can only be used against a single mapped class.

2011-12-28 Thread Kent
in fact, I modified our Query class after .first() was being abused out of laziness: def first(self): raise ProgrammingError(Never use .first(); please use .get() or .one()\n .one() makes sure there is only one return and .get() returns None if doesn't exist.\n