python - How do you bind variables in cx_Oracle with Python3.x? -


i hope can me out i've been stuck while. first time posting here , not. i'll preface saying i'm automation tester has bit of python experience no expert.

i've been racking brain trying around problem , don't know whether it's limitation of cx_oracle or can't find similar problem. have pretty no prior experience cx_oracle.

so, here's little example of i'm trying do. can't post whole thing because it's bit of mess how i've altered , moved things around. i'm going try , basic version of have;

    def test(self):         #driver set         var1 = driver.find_element_by_name('blah').text         var1 = str(var1)         #do other stuff on page         return var1      def foo():         #setup cx_oracle , connect db         sql = ('select value table ref = :1')         c.execute(sql, (var1,)         #verify results of query      class testcase(unittest.testcase):         def test_case(self):             setup(self)             test(self)             foo() 

there no error messages or that. doesn't seem see value of variable. when hardcode value of var1 works , returns results if had queried db through dbeaver.

i've tried putting in same function , same results.

i tried passing var1 around below , still same results:

    def test(self):         #driver set         var1 = driver.find_element_by_name('blah').text         #do other stuff on page         return var1      def foo(var1):         #setup cx_oracle , connect db         sql = ('select value table ref = :1')         c.execute(sql, (var1,))         #verify results of query      class testcase(unittest.testcase):         def test_case(self):             setup(self)             var1 = test(self)             print (var1)             foo(var1) 

i've been using this reference binding variables none of methods work me.

so, in summary, have 2 functions , want pass variable 1 other cx_oracle doesn't seem it. chose cx_oracle because pyodbc , pypyodbc didn't seem want connect oracle 10g db i'm trying talk to. i'm open using tool if knows better one?

if need more details, let me know.

you can use string.format build sql

def foo(var1):     #setup cx_oracle , connect db     sql = 'select value table ref = {}'.format(var1)     c.execute(sql) 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -