[Tutor] Fwd: Problems with parameter queries
Eduardo Vieira
eduardo.susan at gmail.com
Thu Jun 25 17:13:21 CEST 2009
On Wed, Jun 24, 2009 at 6:16 PM, Richard
Lovely<roadierich at googlemail.com> wrote:
> (oops... forgot to reply-all)
>
>
> ---------- Forwarded message ----------
> From: Richard Lovely <roadierich at googlemail.com>
> Date: 2009/6/25
> Subject: Re: [Tutor] Problems with parameter queries
> To: Eduardo Vieira <eduardo.susan at gmail.com>
>
>
> 2009/6/24 Eduardo Vieira <eduardo.susan at gmail.com>:
>> Hello, I am accessing a Pervasive SQL data source using odbc and I'm
>> having this trouble:
>>
>> import dbi
>> import odbc
>> # the first execute works
>> pnumber = '09F153'
>> wh = '00'
>> qty = 3
>> myconn = odbc.odbc('DSN=MKPT01')
>> mycursor = myconn.cursor()
>> mycursor.execute("""
>> SELECT "INVENTORY"."CODE", "INVENTORY"."INV_DESCRIPTION" FROM "INVENTORY"
>> WHERE "INVENTORY"."CODE" = ? AND WHSE = ?
>>
>> """, [pnumber, wh])
>> results = mycursor.fetchall()
>>
>> print results
>>
>> # this one below doesn't
>>
>> mycursor.execute("""UPDATE INVENTORY SET ONHAND = ?
>> WHERE CODE = ? AND WHSE = '00'
>>
>> """, [pnumber, qty])
>> #mycursor.commit()
>> mycursor.close()
>>
>> If I don't use parameter in the update code, it updates fine. Am I
>> missing something? Is this a problem specific to the Pervasive SQL?
>> For example, this works:
>> mycursor.execute("""UPDATE INVENTORY SET ONHAND='0'
>> WHERE CODE = '09F153' AND WHSE = '00'
>>
>> """)
>>
>> Thanks
>>
>> Eduardo
>> _______________________________________________
>> Tutor maillist - Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
> Isn't the arguement list to the non-working query back-to-front?
>
> --
> Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
> www.theJNP.com
>
>
>
Oops! My bad, I guess that was the problem. I'm going to test it soon.
Thanks for spotting that!
More information about the Tutor
mailing list