Press "Enter" to skip to content

How to Save Data in Oracle Database Using Python?

Use connection.commit() method to save data in Oracle Database using Python. The below is an example:

Save Data in Oracle Database Using Python Example

In the following Python program, it will create the connection using the cx_Oracle library in variable CONN and then will execute an update statement to update EMP table’s comm column. After that, before closing the Oracle database connection, it will save the changes using the COMMIT() method.

import cx_Oracle

conn = cx_Oracle.connect("scott", "tiger", "localhost:1521/orcl")

cur = conn.cursor()

cur.execute('update emp set comm = sal * 10 / 100')

conn.commit()
cur.close()
conn.close()

See also:

Have you found the answer to your question? If not, you can discuss it with me in the comments section below or join my Q&A community OrclQA.com for developers and ask your question. It is FREE.

Vinish Kapoor

Follow

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. foxinfotech.in 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.

guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Imran Syed
Imran Syed
2 months ago

Hi,

I need python script to pull the data from Oracle database and insert into Postgresql database.

could you please help me.

Regards,
Imran