Rick,
On Jan 10, 7:02 pm, "Rick Morrison" <[EMAIL PROTECTED]> wrote:
> For a stepwise migration from raw, SQL, it will probably be easier to get
> your mind around the SQL-expression side of the library, and then adopt ORM
> features as you feel comfortable with them.
>
> On the SQL-expression side of the library, you'll find that your Table()
> object has a collection called "c" (for Columns). It's a dict-like
> collection that supports retrieving the column by name:
>
> Table.update() takes a dictionary of updates, so the name-based access is
> already in there:
>
> tbl.update(tbl.c.dateworked == mydate).execute(dict(columnname =
> newvalue))
>
> or using sessions:
>
> S.execute(tbl.update(tbl.c.dateworked == mydate), dict(columnname
> = newvalue))
>
> HTH,
> Rick
Sorry I didn't reply sooner. I got busy with other things at work last
week. To use your first suggestion, I would have to use a series of if
statements like below, correct?
if colName == 'someColName':
tbl.update(tbl.c.dateworked == mydate).execute(dict(columnname
=newvalue))
elif colName == 'anotherColName':
tbl.update(tbl.c.dateworked ==
mydate).execute(dict(othercolumnname =newvalue))
else:
pass
This will work, but it's not quite as elegant as I had hoped. The
sessions method looks like it would have the same issue. Thanks for
the advise.
Mike
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---