JavaScript
x
12
12
1
import cx_Oracle
2
3
dsn_tns = cx_Oracle.makedsn('**********', '*******', service_name='***')
4
5
conn = cx_Oracle.connect(user='******', password='*******', dsn=dsn_tns)
6
7
c = conn.cursor()
8
c.execute('select username,created from dba_users where username='USERNAME' ')
9
for row in c:
10
print (row[0], '-', row[1]) # this only shows the first two columns. To add an additional column you'll need to add , '-', row[2], etc.
11
conn.close()
12
JavaScript
1
5
1
File "*******************", line 9
2
c.execute('select username,created from dba_users where username='MONITOR' ')
3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4
SyntaxError: invalid syntax. Perhaps you forgot a comma?
5
WHat is wrong here , when I using single quote around username then I am getting this error .
Advertisement
Answer
JavaScript
1
5
1
c.execute(
2
"""select username, created from dba_users where username=:USERNAME""",
3
USERNAME = 'Cristiano Ronaldo'
4
)
5