BTW, aliased() and alias() don't work on a label() either. I tried
passing the label object straight into the order_by() as well to no
avail. I'm all out of ideas.
On Jan 9, 3:47 am, Yuen Ho Wong wyue...@gmail.com wrote:
Hi,
I have a rather complicated problem and I was wondering if you guys
Except that LIMIT and OFFSET are present in my query, gnarly isn't
it ? :P
d = label(distance,
some_complicated_geoalchemy_function_call(columns...))
q = session.query(Product, Merchant.location, d)\
.join(Merchant, Product.merchant_id == Merchant.id)\
Here are the models:
class Merchant(Base):
__tablename__ = merchant
id = Column(Integer, autoincrement=True, primary_key=True)
location = GeometryColumn(Point, nullable=False)
class SearchOption(Base):
__tablename__ = searchoption
id = Column(Integer, autoincrement=True,
On Jan 8, 2012, at 3:16 PM, Yuen Ho Wong wrote:
Except that LIMIT and OFFSET are present in my query, gnarly isn't
it ? :P
d = label(distance,
some_complicated_geoalchemy_function_call(columns...))
q = session.query(Product, Merchant.location, d)\
.join(Merchant,
Hi,
you need to join explicitly on A.b:
SESSION.query(A).join(A.b).order_by(B.name)
Full example: http://pastebin.com/uMqEa6Cr
Regards,
- Gulli
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To view this discussion on the web visit
Hi Michael,
Thanks for your quick reply.
I understand.
I am using SQLite as the engine.
I have not found the functions needed in the doc.
I will leave this sort option open and stick with SQlite for a while.
Frans
Op 1/10/2011 4:03 PM, Michael Bayer schreef:
you'd need to use SQL
forget it, I missed this in the docs :
Note that when using joined eager loaders with relationships, the
tables used by the eager load’s join are anonymously aliased. You can
only order by these columns if you specify it at the relationship()
level. To control ordering at the query level
I got it:
from sqlalchemy.sql import func
stmt = session.query(Prod.store_id,
func.count('*').label('prod_count')).group_by(Prod.store_id).subquery()
obj_q = session.query(Store, stmt.c.prod_count).outerjoin(
(stmt,
Store.id==stmt.c.store_id)).order_by(stmt.c.prod_count.desc())
On Friday 19 December 2008 19:53:03 有末 清華 wrote:
Hi. Well, I want to output the HTML code from database. And the
HTML code should be order by 'cost' and group_by 'category'
The database table is like below.
---
ID CategoryName
I found the solution using Joins. Thanks anyways.
This is it:
query = session.query(A).select_from(join(A, B)).order_by(B.some_attr)
cheers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post
On Dec 5, 2007, at 1:56 PM, David Gardner wrote:
I have three tables a(a query of a really), b, c
a has a 1-many relationship with b
c has a 1-many relationship with b
What I would like to do is in my mapper for table c, is sort the order
of rows from b by a.name.
I don't know how to
Michael thanks for the help, this is how I was able to get it working.
Probably isn't the most efficient, but it works, I couldn't implement it
the way you proposed because I still need to be able to do a_row = b_row.A
-
sql_b = select([b_table, sql_a.c.name], b_table.c.a_id =
On Oct 1, 2007, at 8:20 AM, [EMAIL PROTECTED] wrote:
Hi Michael, thanks for the help!
The documentation mentions that this option over-rides the per-engine
configuration but I couldn't find a create_engine option to set this.
Any reference would be greatly appreciated!
uhhh there is no
On Sep 28, 2007, at 3:00 PM, [EMAIL PROTECTED] wrote:
Hi,
While trying to debug my script I set echo=True and checked the SQL
statements that are generated. I noticed that all of the SELECTs
issued to the DB have the ORDER_BY clause -- even though I didn't
explicitly specify order_by()
On 4/19/07, Michael Bayer [EMAIL PROTECTED] wrote:
On Apr 19, 2007, at 9:39 AM, Gaetan de Menten wrote:
By the way, lately I've been wishing SQLAlchemy would add a column
(and possibly its table) automatically to the select clause if I do an
order by a column which is not in the
On Apr 18, 2007, at 12:21 AM, Chris Shenton wrote:
I'm using SQLAlchemy with Pylons and query my 'system' table and order
by their client_id field like:
from er.models import System, Vendor, Client
sys = self.session.query(System).select(System.c.lastseen
self.this_week,
e.g. order_by = [desc(table1.mycol)]
Disrupt07 napsal(a):
In my table I have a column with type Boolean. When using order_by on
this column I am getting the results as follows:
False
False
True
True
True
...
True
I want them the other way round (the True first, then the False).
@ml
Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more
Michael Bayer wrote:
use 'sites':relation(Site, backref=backref('attachments',
order_by=attachment_table.c.name)) for now.
Ok, should I open a ticket for that ?
On Mar 30, 5:50 am, Alexandre CONRAD [EMAIL PROTECTED] wrote:
Hello,
I have a problem with order_by on a many-to-many
use 'sites':relation(Site, backref=backref('attachments',
order_by=attachment_table.c.name)) for now.
On Mar 30, 5:50 am, Alexandre CONRAD [EMAIL PROTECTED] wrote:
Hello,
I have a problem with order_by on a many-to-many relationship (using
assign_mapper):
--
Manlio Perillo ha scritto:
[...]
op = (a.c.x / a.c.y).label('z')
query = select([op], order_by=[op], use_labels=True)
The solution is quite simple (and very elegant):
s = select([op], use_labels=True)
s.order_by(s.c.z)
Regards Manlio Perillo
Manlio Perillo wrote:
try:
conn = db.connect()
i = a.insert()
conn.execute(i, x=6, y=5)
op = (a.c.x / a.c.y).label('z')
query = select([op], order_by=[op], use_labels=True)
result = conn.execute(query).fetchall()
for r in result:
print r
finally:
22 matches
Mail list logo