database questions ala newbie pythonist
Uwe Grauer
news at grauer-online.de
Thu Dec 2 06:25:01 EST 2004
More information about the Python-list mailing list
Thu Dec 2 06:25:01 EST 2004
- Previous message (by thread): database questions ala newbie pythonist
- Next message (by thread): database questions ala newbie pythonist
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Weinhandl Herbert wrote:
> chris wrote:
>
> ...
>
>
>> This works fine using the literals 0 (For Delstatus) and 1190 (for
>> ProductID)
>> But when I try to use a variable such as:
>>
>> ###################################################################
>> ...
>> varA = '0'
>> varB = '1190'
>> mycursor.execute('Update Categories Set DelStatus = ' varA 'Where
>> ProductID
>> = ' varB)
>
>
> use string formatting expressions
> (which are easier to handle than string concatenation) :
>
> 'UPDATE Categories SET DelStatus=%d WHERE ProductID=%s;' % (varA,'1190')
>
> or maybe
>
> "UPDATE Categories SET DelStatus='%d' WHERE ProductID='%d';" % (0,varB)
>
> if your DB wants your int's as string
>
>
You could also use:
curs.execute('UPDATE Categories SET DelStatus=? WHERE ProductID=?;',
(varA, 1190))
Uwe
- Previous message (by thread): database questions ala newbie pythonist
- Next message (by thread): database questions ala newbie pythonist
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list