[sqlalchemy] iteration over mapper

2007-01-31 Thread Jose Soares
Hi all, Probably this is a stupid question, :-[ but I don't understand how to iterate an object mapper to get fields value. --- user = session.query(User).select(id=1) for j in user.c: print j.name logname id password for j in user.c: print j.value 'Column' object has no attribute

[sqlalchemy] Re: iteration over mapper

2007-01-31 Thread svilen
Hi all, Probably this is a stupid question, :-[ but I don't understand how to iterate an object mapper to get fields value. --- user = session.query(User).select(id=1) for j in user.c: print j.name logname id password these are the column-names that your query-result has. It is

[sqlalchemy] Re: iteration over mapper

2007-01-31 Thread King Simon-NFHD78
Jose Soares wrote: Hi all, Probably this is a stupid question, :-[ but I don't understand how to iterate an object mapper to get fields value. --- user = session.query(User).select(id=1) for j in user.c: print j.name logname id password for j in user.c: print

[sqlalchemy] date format

2007-01-31 Thread Jose Soares
Hi all, I would like to display my dates with format '%d/%m/%Y' instead of ISO format. qry = session.query(Nazione).select(Nazione.c.codice=='201') qry[0].data_inizio print qry[0].data_inizio 2006-01-14 Is there a way to set it in SA without using a customer function ? jo

[sqlalchemy] Re: date format

2007-01-31 Thread Guy Hulbert
On Wed, 2007-31-01 at 17:50 -0400, Jose Soares wrote: Hi all, I would like to display my dates with format '%d/%m/%Y' instead of ISO format. qry = session.query(Nazione).select(Nazione.c.codice=='201') qry[0].data_inizio print qry[0].data_inizio 2006-01-14 Is there a way to set

[sqlalchemy] Re: date format

2007-01-31 Thread Guy Hulbert
On Wed, 2007-31-01 at 12:17 -0500, Guy Hulbert wrote: I would like to display my dates with format '%d/%m/%Y' instead of ISO format. qry = session.query(Nazione).select(Nazione.c.codice=='201') qry[0].data_inizio print qry[0].data_inizio 2006-01-14 Is there a way to set

[sqlalchemy] Re: polymorphic mapping with more than 2 level of inheritance

2007-01-31 Thread svilen
sorry, there was one more quoting fix that was needed. passes with PG on 2274. IMO even some more. see ansisql.py, format_column(), any sqlalchemy.sql._ColumnClause falls into the literal case, and is not quoted (try with zz.py, the py_a.dataC). Also see schema.py, the copy() and the

[sqlalchemy] sorting mapped class by joined subquery result (error)

2007-01-31 Thread Dennis
I have a mapped class.. lets call it Data with a few properties Data.id (primary key), Data.a, Data.b, Data.c I want to query a few of these objects out.. but they need to be sorted by some arbitrary data arbitrary_data=select ( [Data.c.id, OtherClass.c.somedata],

[sqlalchemy] Re: any particular reason for creating unused lists?

2007-01-31 Thread svilen
another things i noted: - using value.lower() == value instead of value.islower() - ansisql.py: in _requires_quotes(): this bool(len([x for x in str(value) if x not in self._legal_characters()])) should be same as bool( s.translate( 256*' ', self._legal_characters() ) )

[sqlalchemy] Re: polymorphic mapping with more than 2 level of inheritance

2007-01-31 Thread Michael Bayer
what are there like 10 .py attached scripts that ive to look at now ? ive completely lost track. post tickets for the important ones. On Jan 31, 12:42 pm, svilen [EMAIL PROTECTED] wrote: sorry, there was one more quoting fix that was needed. passes with PG on 2274. IMO even some more.

[sqlalchemy] Re: any particular reason for creating unused lists?

2007-01-31 Thread Michael Bayer
On Jan 31, 1:28 pm, svilen [EMAIL PROTECTED] wrote: another things i noted: - using value.lower() == value instead of value.islower() - ansisql.py: in _requires_quotes(): this bool(len([x for x in str(value) if x not in self._legal_characters()])) should be same as

[sqlalchemy] Re: sorting mapped class by joined subquery result (error)

2007-01-31 Thread Michael Bayer
quick easy fix is to use result set mapping instead, or feed a full select() statement into query.select(), which will skip the whole compilation step. i would like a small test case attached for this one so i can play with it, though. for example i dont see why its deciding to use the nesting

[sqlalchemy] Re: sorting mapped class by joined subquery result (error)

2007-01-31 Thread Dennis
Sorry if this posts twice... I didn't get a Message has been sent page last time.. I posted a bug with a test case here: http://www.sqlalchemy.org/trac/ticket/449 Thanks Dennis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

[sqlalchemy] Re: sorting mapped class by joined subquery result (error)

2007-01-31 Thread Dennis
I've created a bug with an attached test: http://www.sqlalchemy.org/trac/ticket/449 Thanks! -Dennis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: custom sql.

2007-01-31 Thread Brent Pedersen
hi, i've got it this far now. but it doesnt like the q.address.lat/lon since it makes an alias in the join. how to i get at that alias? sajoin = q.join_to('address') sorder = ABS( + str(q.address.lat) + - %f) + ABS( + str(q.address.lon) + - %f) sorder %= (lat,lon)

[sqlalchemy] Re: sorting mapped class by joined subquery result (error)

2007-01-31 Thread Dennis
Just a quick note, I tried out your suggestion to pass in a select statement. That does indeed work. There is an issue though, I tried using the contains_eager('myproperty') as noted in the docs and that only worked in combination with eagerload('myproperty'). I think the reason is that in the

[sqlalchemy] Re: sorting mapped class by joined subquery result (error)

2007-01-31 Thread Michael Bayer
On Jan 31, 4:57 pm, Dennis [EMAIL PROTECTED] wrote: little confusing, but perhaps it is supposed to be that way. I would have thought that contains_eager implies eagerload. great idea. i threw that into rev 2284. --~--~-~--~~~---~--~~ You received this

[sqlalchemy] Re: any particular reason for creating unused lists?

2007-01-31 Thread sdobrev
another things i noted: - using value.lower() == value instead of value.islower() - ansisql.py: in _requires_quotes(): this bool(len([x for x in str(value) if x not in self._legal_characters()])) should be same as bool( s.translate( 256*' ',

[sqlalchemy] Re: custom sql.

2007-01-31 Thread Michael Bayer
use func.abs(q.address.lat) for the ABS function. On Jan 31, 2007, at 4:24 PM, Brent Pedersen wrote: hi, i've got it this far now. but it doesnt like the q.address.lat/lon since it makes an alias in the join. how to i get at that alias? sajoin = q.join_to('address')

[sqlalchemy] Re: custom sql.

2007-01-31 Thread Brent Pedersen
ah. that makes sense. here's my working query. returns results in order of distance to a point (lat,lon): q = session.query(Student) j = q.join_to('address') return q.select( j,order_by=asc(func.abs(address.c.lat -lat) + func.abs(address.c.lon-lon))