Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parameterized SQL query
#2
From your own link: http://www.oracle.com/technetwork/articl...05.html#t7
Quote:
import cx_Oracle

con = cx_Oracle.connect('pythonhol/[email protected]/orcl')

cur = con.cursor()
cur.prepare('select * from departments where department_id = :id')

cur.execute(None, {'id': 210})
res = cur.fetchall()
print res

cur.execute(None, {'id': 110})
res = cur.fetchall()
print res

cur.close()
con.close()

Using :1 might work for a tuple of params, but it looks like the recommended way is to use named params with a dict.
Reply


Messages In This Thread
Parameterized SQL query - by purnima1 - Oct-10-2017, 01:15 PM
RE: Parameterized SQL query - by nilamo - Oct-10-2017, 03:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Parameterized math calculations? babaliaris 7 16,990 Jun-01-2022, 10:19 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020