I'm trying to query oracle db.
import cx_Oracle
dsn_tns = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=some.server.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=service_name)))'
con = cx_Oracle.connect('USER', 'PWD', dsn_tns)
cur = con.cursor()
cur.execute('select * from admin.summary where NUMBER = "C123456"')
res = cur.fetchall()
print res
cur.close()
con.close()
And got:
$ python cx_oracle.py
Traceback (most recent call last):
File "cx_oracle.py", line 9, in <module>
cur.execute('select * from admin.summary where NUMBER = "C123456"')
cx_Oracle.DatabaseError: ORA-00936: missing expression
I also tried to change query string to
'select * from admin.summary where NUMBER = 'C1012445''
And got:
$ python cx_oracle.py
File "cx_oracle.py", line 9
cur.execute('select * from admin.summary where NUMBER = 'C1012445'')
^
SyntaxError: invalid syntax
Any suggestion? Python version is 2.7
cur.execute("select * from admin.summary where NUMBER = 'C123456'")does it work?select sysdate from dual;work? Try also without the;Let me know if this works$ python cx_oracle.py [(datetime.datetime(2019, 2, 18, 16, 10, 32),)]select * from admin.summarywork? Also what is the version of your Oracle DB?