I have found the answer:

table.update(values={table.c.id:myNewSequenceNumber}).execute()


On Aug 29, 4:33 pm, "alex.schenkman" <[EMAIL PROTECTED]> wrote:
> Hi:
>
> I'm new to SQL.
> I have to execute the following SQL line, which updates a sequence
> number. The table zseq_document_types_lookup has only one record with
> this number.
>
> update zseq_document_types_lookup set id=2;
>
> I thought of retrieving the record with something like this:
>
> class Sequence(object):
>    pass
>
> def someFunction():
>     db = create_engine( ... )
>     metadata = BoundMetadata( db )
>     session = create_session( bind_to = self.db )
>     table = Table('zseq_document_types_lookup', metadata,
> autoload=True)
>     mapper(Sequence, table)
>
>     'Fetch the only record in the table'
>     sequenceNumber = session.query(Sequence).selectfirst()
>
>     'Increment the sequence number'
>     sequenceNumber.id += 1
>
>     session.flush()
>
> BUT, it doesn't work. I get an error "Can't change the identity of
> instance sequenceNumber"
>
> My guess is that there is a better way of updating this record...
>
> Thanks in advance!


--~--~---------~--~----~------------~-------~--~----~
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