dbTalk Databases Forums  

[Info-Ingres] Using parameter place holders with Python

comp.databases.ingres comp.databases.ingres


Discuss [Info-Ingres] Using parameter place holders with Python in the comp.databases.ingres forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Martin Bowes
 
Posts: n/a

Default [Info-Ingres] Using parameter place holders with Python - 07-19-2011 , 05:40 AM






Quote:
From the spec (http://www.python.org/dev/peps/pep-0249/), it seems that youshould be able to provide the parameters as arguments to the execute() function, like this:

rs = cur.execute("INSERT INTO steering_file_entry (id,galaxy_id,comparison,notes,auth)\
VALUES (?,?,?,?,'import')", getID(),fk_galaxyID,fk_comparison,fk_notes)

or this

rs = cur.execute("INSERT INTO steering_file_entry (id,galaxy_id,comparison,notes,auth)\
VALUES (:a,:b,:c,:d,'import')", getID(),fk_galaxyID,fk_comparison,fk_notes)

but both of those gave me

ingresdbi.InterfaceError: usage: cursor.execute()

Does anyone have any idea what I'm doing wrong?

Martin Bowes

Reply With Quote
  #2  
Old   
Uwe Stelling
 
Posts: n/a

Default Re: [Info-Ingres] Using parameter place holders with Python - 07-19-2011 , 08:36 AM






cursor.execute expects 2 parameters, first the operation, second a tuple (or list) with all parameters in it. In the example, cur.execute is called with 5 parameters. Use round braces around the 4 values or use

op = "INSERT INTO xxx (yyy, zzz) VALUES(?,?)"
pa = (id, galaxy_id)
rs = cur.execute(op, pa)

Uwe Stelling

Martin Bowes wrote:
Quote:
From the spec (http://www.python.org/dev/peps/pep-0249/), it seems that you should be able to provide the parameters as arguments to the execute() function, like this:


rs = cur.execute("INSERT INTO steering_file_entry (id,galaxy_id,comparison,notes,auth)\
VALUES (?,?,?,?,'import')", getID(),fk_galaxyID,fk_comparison,fk_notes)

or this

rs = cur.execute("INSERT INTO steering_file_entry (id,galaxy_id,comparison,notes,auth)\
VALUES (:a,:b,:c,:d,'import')", getID(),fk_galaxyID,fk_comparison,fk_notes)

but both of those gave me

ingresdbi.InterfaceError: usage: cursor.execute()

Does anyone have any idea what I'm doing wrong?

Martin Bowes




------------------------------------------------------------------------

_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://ext-cando.kettleriverconsulti...fo/info-ingres

Reply With Quote
  #3  
Old   
Martin Bowes
 
Posts: n/a

Default Re: [Info-Ingres] Using parameter place holders with Python - 07-20-2011 , 02:13 AM



Thanks Uwe.

That did the trick!

Marty

-----Original Message-----
From: Uwe Stelling [mailto:stelling (AT) sdac (DOT) hannover.bgr.de]
Sent: 19 July 2011 14:37
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] Using parameter place holders with Python

cursor.execute expects 2 parameters, first the operation, second a tuple (or list) with all parameters in it. In the example, cur.execute is called with 5 parameters. Use round braces around the 4 values or use

op = "INSERT INTO xxx (yyy, zzz) VALUES(?,?)"
pa = (id, galaxy_id)
rs = cur.execute(op, pa)

Uwe Stelling

Martin Bowes wrote:
Quote:
From the spec (http://www.python.org/dev/peps/pep-0249/), it seems that you should be able to provide the parameters as arguments to the execute() function, like this:


rs = cur.execute("INSERT INTO steering_file_entry (id,galaxy_id,comparison,notes,auth)\
VALUES (?,?,?,?,'import')", getID(),fk_galaxyID,fk_comparison,fk_notes)

or this

rs = cur.execute("INSERT INTO steering_file_entry (id,galaxy_id,comparison,notes,auth)\
VALUES (:a,:b,:c,:d,'import')", getID(),fk_galaxyID,fk_comparison,fk_notes)

but both of those gave me

ingresdbi.InterfaceError: usage: cursor.execute()

Does anyone have any idea what I'm doing wrong?

Martin Bowes




------------------------------------------------------------------------

_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://ext-cando.kettleriverconsulti...fo/info-ingres

_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://ext-cando.kettleriverconsulti...fo/info-ingres

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.