If you want to do UPDATEs from the ORM, often an easy way is to just use 
session.query(User).update({'username':'foobar'}, False).

But, the column mapped attributes on your mapped class functions as an alias 
for the Column expression in most cases, and is interchangeable with 
table.c.column:

        usertable.update().values({User.username:'foobar'})

You can also get at the Column object directly:

        User.username.__clause_element__()



On Dec 9, 2010, at 5:48 PM, Nagy Viktor wrote:

> thanks, this was the problem
> 
> I've had 
> 
> class User(DeclarativeBase):
>     
>     username = Column( UserName, ...)
> 
> is there any way to get UserName back knowing only the "words" User and 
> username?
> 
> Viktor
> 
> On Thu, Dec 9, 2010 at 4:31 PM, Michael Bayer <[email protected]> 
> wrote:
> table.update() requires the "key" of the Column object, usually the same as 
> column.name, as the names inside the values dictionary (or better yet, the 
> table.c.mycol object itself as key).  The behavior below suggests "mycol" is 
> not available as table.c.mycol.
> 
> 
> On Dec 9, 2010, at 5:23 AM, Nagy Viktor wrote:
> 
> > Hi,
> >
> > it's probably a very simple question, but can't get around it.
> >
> > I run
> >
> > myquery.update(values={'mycol': 0.7})
> >
> > this generates sql:
> >
> > 'UPDATE executieoperatieangajat SET  WHERE 
> > executieoperatieangajat."Operatie" = %(Operatie_1)s AND 
> > executieoperatieangajat."Terminat" = %(Terminat_1)s' {'Operatie_1': 
> > u'denumire9', 'Terminat_1': 0}
> >
> > as you can see, there is a missing part between SET and WHERE
> >
> > what do I do wrong?
> >
> > mycol is a column attribute in a declaratively given table
> >
> > thanks, Viktor
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sqlalchemy" group.
> > To post to this group, send email to [email protected].
> > 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.
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> 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.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
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