Re: [sqlalchemy] a [probably] stupid query question

2014-03-20 Thread Richard Gerd Kuesters
thanks again, AM. no need to have this extra trouble, as I just asking this as a matter of curiosity. it thought it was something rather simple as hell :) best regards, richard. On 03/19/2014 09:50 PM, AM wrote: Not at my desk so I cannot test this, but IIRC in the select you can specify

[sqlalchemy] session.merge behaviour in case of String type primary keys

2014-03-20 Thread RedBaron
Hi, It looks like session.merge() converts String type primary key to its lower-case equivalent before processing. from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, scoped_session from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import

Re: [sqlalchemy] session.merge behaviour in case of String type primary keys

2014-03-20 Thread Michael Bayer
On Mar 20, 2014, at 7:46 AM, RedBaron dheeraj.gup...@gmail.com wrote: Hi, It looks like session.merge() converts String type primary key to its lower-case equivalent before processing. T1 = Test1('A','My name is a') session.merge(T1) session.commit() T2 = Test1('a','My name is

Re: [sqlalchemy] label column_descriptions

2014-03-20 Thread Michael Bayer
On Mar 19, 2014, at 2:49 PM, lars van gemerden l...@rational-it.com wrote: Hi all, I solved this before, but i took me half a day and a lot of guessing and i forgot. If i add (sometimes calculated) columns to a query and i want to set the names manually (via label()?), how do i do

[sqlalchemy] Re: label column_descriptions

2014-03-20 Thread lars van gemerden
I solved it (again): for future reference: say you have the expression Person.name (Person is SQLA class) to use in a query, to have a label show up under that name in the resulting KeyedTuple's: to do: Person.name.label(something) is not enough, you have to do: expr =

[sqlalchemy] Re: label column_descriptions

2014-03-20 Thread lars van gemerden
thanks, Michael, we crossed responses; i thought it was something like that, but there are some gotchas (at least for me; see above). CL On Thursday, March 20, 2014 2:22:24 PM UTC+1, lars van gemerden wrote: I solved it (again): for future reference: say you have the expression

Re: [sqlalchemy] a [probably] stupid query question

2014-03-20 Thread Ladislav Lenart
Hello. On 20.3.2014 12:13, Richard Gerd Kuesters wrote: thanks again, AM. no need to have this extra trouble, as I just asking this as a matter of curiosity. it thought it was something rather simple as hell :) I think the following: q = session.query(A, B).filter(A.b_id == B.id) print q #

Re: [sqlalchemy] label column_descriptions

2014-03-20 Thread Michael Bayer
On Mar 20, 2014, at 9:22 AM, lars van gemerden l...@rational-it.com wrote: I solved it (again): for future reference: say you have the expression Person.name (Person is SQLA class) to use in a query, to have a label show up under that name in the resulting KeyedTuple's: to do:

Re: [sqlalchemy] a [probably] stupid query question

2014-03-20 Thread Richard Gerd Kuesters
thanks Ladislav! yup, that one gives me what i want, but i was kinda working on plain select([col1, col2], from_obj=) function :) but nevermind bothering, its just part of a building process that's i'm writing in SA (instead of making them by hand), people are used to do selects like

Re: [sqlalchemy] a [probably] stupid query question

2014-03-20 Thread Richard Gerd Kuesters
well ... just bumped at Bundle. it does the job :) http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html?highlight=aliased#sqlalchemy.orm.query.Bundle best regards, richard. On 03/20/2014 02:20 PM, Richard Gerd Kuesters wrote: thanks Ladislav! yup, that one gives me what i want, but i was

Re: [sqlalchemy] label column_descriptions

2014-03-20 Thread lars van Gemerden
Hi Michael, OK, that's why. Below are the stack traces. They are not the same for A.b and A_b. If i use other labels this error does not happen. cheers, lars with expr.label( %s_%s % (cls.__name__, attr_name)): File C:\python27\lib\site-packages\bottle.py, line 781, in _handle return

[sqlalchemy] Argument to LIMIT must be a number?

2014-03-20 Thread Ryan Kelly
Hi: It seems that the argument to query.limit must be a number. However, NULL (which I imagine could be passed by the null() construct or as a string) and ALL (which, I suppose could be text(ALL) or literal(ALL) or just the string ALL) are perfectly acceptable values on PostgreSQL. Is there some

Re: [sqlalchemy] Argument to LIMIT must be a number?

2014-03-20 Thread Michael Bayer
LIMIT NULL and LIMIT ALL per the PG docs at http://www.postgresql.org/docs/9.0/static/queries-limit.html are the same as omitting the number.These would appear to be syntactical helpers that you wouldn't really need when working with a select() construct (unless you're trying to get at

Re: [sqlalchemy] Argument to LIMIT must be a number?

2014-03-20 Thread Ryan Kelly
Redshift needs LIMIT ALL to avoid attempting an optimization which causes it to crash. Note that OFFSET 0 is the same as omitting OFFSET, but it acts as an optimization fence. This, I suppose, is a similar thing. -Ryan Kelly On Thu, Mar 20, 2014 at 5:38 PM, Michael Bayer

Re: [sqlalchemy] Argument to LIMIT must be a number?

2014-03-20 Thread Michael Bayer
the int() catch here on limit/offset is something we added due to user report which raised the issue that it's a security hazard, back when we used to render the given value directly in the SQL without using a bound parameter. We fixed both that it allowed non-int values as well as that it