Oct-03-2017, 10:40 AM
Hi Larz ,
Thanks for explaining it . I know Why this is happening but I am not getting how to remove ' from string .
I will share updated code .
I am trying to remove these single quotes but not getting anything.
Please help me with this
Thanks for explaining it . I know Why this is happening but I am not getting how to remove ' from string .
I will share updated code .
import cx_Oracle from datetime import datetime #reading query from file f = open('C:/Users/pubhatia/Documents/learning/python/query/test.sql') #print(f.read()) filer = f.read() print(filer) print(repr(filer)) f.close() #filer3=filer #source_name ='PWS' filer=filer.replace("\'","") #print( repr(filer3 ) filer2="select * from dual" if filer==filer2: print('same value') else: print ('no same ') #create connection string conn_str = u'user/pwd@database' #setting up connection conn = cx_Oracle.connect(conn_str) c = conn.cursor() c.execute(filer2) start_time = datetime.now() for row in c: print( row) conn.close() end_time = datetime.now() print('Duration: {}'.format(end_time - start_time))
Output:"select * from dual"
'"select * from dual"'
no same
('X',)
Duration: 0:00:01.239932
if u will check there is ' quote attach to it that is why when I trying to run it it is giving me error.I am trying to remove these single quotes but not getting anything.
Please help me with this