On 9/6/07, Lukasz Szybalski <[EMAIL PROTECTED]> wrote:
> On 9/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > On Thursday 06 September 2007 23:03:35 Lukasz Szybalski wrote:
> > > Hello,
> > > So it seems to me there are two select function that I can use but
> > > they are different
> > > First:
> > > s=Users.select(Users.c.LASTNAME=='Smith')
> > > but when you want to select only two columns via :
> > > s=Users.select([Users.c.LASTNAME, Users.c.FIRSTNAME],
> > > Users.c.LASTNAME =='Smith')
> > >
> > > you get an error :
> > >  File
> > > "/usr/lib/python2.4/site-packages/sqlalchemy/ext/assignmapper.py",
> > > line 7, in do
> > >     return getattr(query, name)(*args, **kwargs)
> > > TypeError: select() takes at most 2 arguments (3 given)
> >
> >
> > >
> > >
> > > Second:
> > >
> > > import sqlalchemy
> > > s2=sqlalchemy.select(Users.c.LASTNAME=='Smith')
> > > s3=s2.execute()
> > > This works just fine:
> > > s2=sqlalchemy.select([Users.c.LASTNAME, Users.c.FIRSTNAME],
> > > Users.c.LASTNAME =='Smith')
> > > s3=s2.execute()
> > >
> > > Is this difference suppose to be there? or is it a bug in
> > > assign_mapper?
> > >
> > > Lucas
> >
> >
> > the first is the ORM query().select() taking only where clause, the
> > second is plain sql select(columns,where,from). To disambiguate,
> > first one is discontinued and is replaced by filter().
> >
> So basically the first one does select * from x where y =?
> And you can only substitute x,y,? (Sounds very limiting)
>
> To me TABLENAME.select() should just be a a wrapper to
> sqlalchemy.select().execute()
>
> That way the first accepts the same parameters as before but it will
> also be able to do where and from..??? Yes No?
>
> I am not sure what filter() will be doing differently. I check the
> docs and it sounds to me like you want to filter the results already
> selected?Doesn't that complicate things even more. No I have to know a
> filter function and find out what parameters does it take?  Will
> filter() do the actual select ? How will it be different from query()
> select()? Why are they separated?
>
> I guess this is similar conversation:
> http://groups.google.com/group/sqlalchemy/browse_thread/thread/be0b4d6d793cd6f7/4a283669530e1e86?#4a283669530e1e86
>
> From the docs it seems as with filter you will have to do this to get
> your select statement. That seems to me is over complicating things.
> First you call query then subfunction filter then subfunction order
> then subfunction all? how many levels does it go to?
> "
> session.query(User).filter(User.c.user_name.in_('Ed',
> 'Harry','Mary')).order_by(User.c.user_name).all()
> "
>
> Wouldn't it be easier if we do:
> s2=Users.select(
> Users.c.LASTNAME =='Smith'
> )
> or
> s2=Users.select(
> [Users.c.LASTNAME, Users.c.FIRSTNAME],
> Users.c.LASTNAME =='Smith'
> )
> or
> s2=Users.select(
> [Users.c.LASTNAME, Users.c.FIRSTNAME],
> Users.c.LASTNAME =='Smith',
> order_by(User.c.FIRSTNAME)
> )
> or
> s2=Users.select(
> [Users.c.LASTNAME, Users.c.FIRSTNAME],
> Users.c.LASTNAME =='Smith',
> order_by(User.c.FIRSTNAME,ASC),
> limit(1)
> )
>
> there would be another option for  join, etc that could be included in
> the list if one needed to use more. Each of them are optional.
>
> Otherwise questions arise:
> which one do i do  filter(), filter_by(), query() select() select_by()
> Is order_by a passed in parameter or function of a filter() or query()
> or is it ?
> Why do I have to specify all()? Shouldn't  that be a default?
> What is the order of functions to call? Which one is used on what?
>
> What you guys think?
>
> Lucas
>


ok. So this time I am trying to get data from my widget from database
that has two compound keys, using assign_mapper.
#Initialize:
User_table = sqlalchemy.Table('User', metadata, autoload=True)
class User(object):
    pass
usermapper=assign_mapper(session.context,User,user_table)

#get my record:
 x=model.User.get(343,2)

Why do I get an error? What am I doing wrong here?

File "/home/lucas/web/tg/quote/quote/controllers.py", line 126, in upddriver
    x=model.Bdriver.get(343,2)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/ext/assignmapper.py",
line 7, in do
    return getattr(query, name)(*args, **kwargs)
TypeError: get() takes exactly 2 arguments (3 given)


Lucas

--~--~---------~--~----~------------~-------~--~----~
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 options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to