I want to to query my Oracle DB, but it's not working. I think i'm missing something in formatting but unable to figure out. If i execute the same query in SQL developer, it's returning me results. But in Python it's giving 'SyntaxError: invalid syntax.' error.
import os
import cx_Oracle
import matplotlib.pyplot as plt
import numpy as np
dsn_tns = cx_Oracle.makedsn('host', '1521', service_name='S1')
conn = cx_Oracle.connect(user=r'dev_user', password='Welcome', dsn=dsn_tns)
reportid_count = []
count_ID = []
c = conn.cursor()
query = 'select distinct (LTRIM(REGEXP_SUBSTR(ID, '[0-9]{3,}'), '0')) as ReportID,count(ID) from dev_user.RECORD_TABLE group by ID'
c.execute(query)
#loop through the rows fetched and store the records as arrays.
for row in c:
reportid_count.append(row[0] + ',' + str(row[1]))
count_ID.append(row[1])
for s in reportid_count:
print(s)
'select distinct (LTRIM(REGEXP_SUBSTR(ID, 'so I expect the parser complains at everything after it, starting at[0-9]{3,}.