Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cx_Oracle.DatabaseError: ORA-00933: SQL command not properly ended

I am getting the error cx_Oracle.DatabaseError: ORA-00933: SQL command not properly ended when trying to run the following code. I have used

import cx_Oracle
ip = '127.0.0.1'
port = 1234
SID = 'abcd'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)

conn = cx_Oracle.connect('username', 'password', dsn_tns)
curs = conn.cursor()
curs.execute('select sysdate from dual;')  # Error is here
curs.close()
conn.close()

Running the following works as expected:

conn = cx_Oracle.connect('username', 'password', dsn_tns)
print (conn.version)
conn.close()
like image 938
Morgoth Avatar asked Nov 17 '17 11:11

Morgoth


People also ask

How do I fix Ora-00933 SQL command not properly ended?

To correct this issue, simply go back to the end of the phrase and remove the ORDER BY clause. Be sure to go back to the line prior to the ORDER BY clause and re-insert the statement-ending semi-colon. Another case where the ORA-00933 can occur is when attempting to include an ORDER BY clause with a DELETE statement.

What does Ora-00933 SQL command not properly ended mean?

The message ORA-00933: sql command not properly ended. This error is usually caused by an SQL statement with a clause that is not allowed for that statement. Some examples that might cause this error are: An INSERT statement with an ORDER BY clause or an INNER JOIN.

How do you end a SQL command?

Ending a SQL Command You can end a SQL command in one of three ways: with a semicolon (;) with a slash (/) on a line by itself.

What is cx_Oracle used for?

cx_Oracle is a Python extension module that enables querying and updating of Oracle databases using a database API that is common to all database access modules. A number of extensions to the common database API have also been included in order to take advantage of some of the features available exclusively to Oracle.


1 Answers

You don't need the semicolon at the end of the query, maybe it has something to do with that

like image 75
Arjen Dijkstra Avatar answered Sep 19 '22 16:09

Arjen Dijkstra