cur.execute(""" SELECT location, AVG(temp) as avg_temp FROM (SELECT location,temp, ROWNUM rnum FROM time_series_location_temp ORDER BY avg_temp ASC) WHERE rnum <= 6; """) I'm trying to execute this code but keep running into this error DatabaseError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_17344/3055250712.py in ----> 1 cur.execute(""" 2 SELECT LOCATION_ID, AVG(temp) as avg_temp 3 FROM (SELECT LOCATION_ID,temp 4 FROM time_series_location_temp 5 ORDER BY temp ASC)
DatabaseError: ORA-00933: SQL command not properly ended
What's wrong and how should I re-write it?
I've tries to rewrite it and still the error comes up. I was expecting that the code would run and execute my query correctly
CodePudding user response:
That error almost invariably means that you have left the semicolon on the end of the statement. This is needed in SQL*Plus but needs to be removed when using cx_Oracle (or the new python-oracledb).