[sqlalchemy] Re: Joining three tables - Selecting column from two different tables

2011-01-20 Thread Steve
Hi, Thanks. Worked like a charm. Also thanks for SqlAlchemy. A refreshing change for someone from java background. I am using this with Jython. Thanks for the Jython support also. Steve On Jan 18, 8:54 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 18, 2011, at 9:11 AM, Steve

[sqlalchemy] Re: scalar association_proxy

2011-01-20 Thread AgentOrange
Maybe you can squelch the exception by using a synonym with the descriptor argument to map to a fake property. Oooh, I had not come across this construct before - looks as if it might do exactly what I want. I might even be able to make a decorator that wraps this all up nicely. Thank you

[sqlalchemy] select distinct on a relation to an entity with composite primary key

2011-01-20 Thread NiL
hi list, I have the following (elixir) definitions class Invoice(Entity): user_name = Field(Unicode(255)) item = ManyToOne(Item) class Item(Entity): item_id = Field(Integer, primary_key=True) service_id = Field(Unicode(255), primary_key=True) item_class =

Re: [sqlalchemy] Re: rollback not working

2011-01-20 Thread Michael Bayer
On Jan 20, 2011, at 2:04 AM, bool wrote: If I dont use autocommit:True option, it seems the driver will be in a chained transaction mode and results in every single statement (including selects) being run in a new transaction. This is not desirable either. Is there a way out ? The

Re: [sqlalchemy] select distinct on a relation to an entity with composite primary key

2011-01-20 Thread Michael Bayer
its a little unfortunate that Invoice.item.distinct() is recursion overflowing like that, but in general if you want to select distinct Item objects you'd be saying query(Item).distinct(). not sure I understand what invoices that have distinct items means. I understand invoices that have

[sqlalchemy] Re: select distinct on a relation to an entity with composite primary key

2011-01-20 Thread NiL
Hi Michael, thank you very much for your prompt answer. What I want to achieve is, counting the number of distinct items, grouped by user_name Given Item1: item_id = 1 service_id = 'test' item_class = 'dummy' Item2: item_id = 2 service_id = 'other' item_class = 'dummy'

Re: [sqlalchemy] Re: select distinct on a relation to an entity with composite primary key

2011-01-20 Thread Michael Bayer
from sqlalchemy import func, distinct query(Invoice.user_name, func.count(distinct(Item.id))).join(Invoice.items).group_by(Invoice.user_name) On Jan 20, 2011, at 9:51 AM, NiL wrote: Hi Michael, thank you very much for your prompt answer. What I want to achieve is, counting the number

[sqlalchemy] Re: select distinct on a relation to an entity with composite primary key

2011-01-20 Thread NiL
thanks again but the unicity of Item is guaranteed by the triplet of PK I can't just discriminate the distinct() based on the item_id only (it is not unique by itself in my set of data) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to

Re: [sqlalchemy] Re: select distinct on a relation to an entity with composite primary key

2011-01-20 Thread Michael Bayer
session.query(Invoice.user_name, Item).join(Invoice.item).distinct().from_self(Invoice.user_name, func.count(1)).group_by(Invoice.user_name) On Jan 20, 2011, at 11:45 AM, NiL wrote: thanks again but the unicity of Item is guaranteed by the triplet of PK I can't just discriminate the

[sqlalchemy] SQLAlchemy case insensitive like for unicode word

2011-01-20 Thread proft
Hello! I have gtk application with sqlite db, contain russian words. My model code class Patient(Base): lastname = Column(Unicode) /code Search operation code patients = self.session.query(Patient) lastname = unicode(self.lastname_entry.get_text()) if lastname: patients =

[sqlalchemy] Re: I need a final push

2011-01-20 Thread F.A.Pinkse
Hi All, After some additional peeking around I decided to do a test with SQLAlchemy alone. I took the tutorial fr0m the book Essential SQLAlchemy as my guide. This is what I got working. # testing the func following the tutorial in the book Essential SQLALchemy #pg.25 from sqlalchemy

Re: [sqlalchemy] Re: sqlalchemy rocks my socks off!

2011-01-20 Thread Hector Blanco
+1 2011/1/16 Jan Müller m...@dfi-net.de: +1 On Jan 15, 9:58 am, Eric Ongerth ericonge...@gmail.com wrote: +1 On Jan 13, 5:08 pm, rdlowrey rdlow...@gmail.com wrote: To Michael Bayer: sqlalchemy simplifies my life every day and makes me vastly more productive! Many thanks. --

Re: [sqlalchemy] SQLAlchemy case insensitive like for unicode word

2011-01-20 Thread Michael Bayer
That's SQLite's lower() function. If you'd like to use Python's lower() function, you should call lower() on the string and use column.like(mystring.lower()). But that won't do case-insensitive comparison since you need to call lower() on the database column in the statement. So you really

Re: [sqlalchemy] Re: I need a final push

2011-01-20 Thread Michael Bayer
On Jan 20, 2011, at 4:53 PM, F.A.Pinkse wrote: Hi All, After some additional peeking around I decided to do a test with SQLAlchemy alone. I took the tutorial fr0m the book Essential SQLAlchemy as my guide. very very old outdated book. If you want a current book, go to