Press "Enter" to skip to content

Python – Delete Records From Table in Oracle

In this tutorial, I am giving a Python program example to delete records from the table in Oracle.

Delete from Oracle Table Using Python

The following example uses the cx_Oracle library to connect to Oracle Database from Python and delete the record from the EMP table of SCOTT schema.

import cx_Oracle

con = cx_Oracle.connect('scott/[email protected]:1521/orcl')

def delete_emp(n_empno):
    cur = con.cursor()
    cur.execute("Delete from EMP where empno = :n_empno",
                {'n_empno': (n_empno)})
    if cur.rowcount > 0:
        print('Employee record deleted successfully.')
        print('Delete operation failed.')

# call the delete_emp function by passing a employee id
except Exception as e:


Employee record deleted successfully.

See also:

Vinish Kapoor

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

Comments are closed.