Press "Enter" to skip to content

How to Import CX_Oracle in PyCharm?

You have installed the Python and cx_Oracle package, and now you want to import the cx_Oracle package in PyCharm to use in your Python applications. But to import the cx_Oracle in PyCharm first, you need to install the cx_Oracle package in PyCharm too. Below I am explaining the steps to how to install the cx_Oracle package in PyCharm.

But if you haven’t¬†installed the cx_Oracle package yet, then you can check the following post to how to install cx_Oracle package for Python on Windows.

Follow These Steps to Install and Import CX_Oracle Package in PyCharm

  1. Open PyCharm and then Open your project.
  2. Click on the menu File > Settings and then the Settings window will open.
  3. In the Settings window, click on the Project node to expand and then click on the Project Interpreter.
  4. Then on the right side, click on the + button to open Available Packages window, as shown in below image. Then search for cx_Oracle in the search box. Below you will find the cx_Oracle package. Click on it to select and then click on the Install Package button as shown below.

Install cx_Oracle package in PyCharm

You have installed the cx_Oracle package, and now you can use it in your Python applications by importing it.

Import cx_Oracle in PyCharm Example

import cx_Oracle

connection = cx_Oracle.connect("scott", "tiger", "localhost/orcl")

cursor = connection.cursor()

cursor.execute("""
    SELECT empno, ename
    FROM emp
    WHERE deptno = :did""",
    did = 30)
print("List of Employees in Department: 30")
for fempno, fename in cursor:
    print("Employee No:", fempno, "Employee Name:", fename)

Output

List of Employees in Department: 30
Employee No: 7499 Employee Name: ALLEN
Employee No: 7521 Employee Name: WARD
Employee No: 7654 Employee Name: MARTIN
Employee No: 7698 Employee Name: BLAKE
Employee No: 7844 Employee Name: TURNER
Employee No: 7900 Employee Name: JAMES

Process finished with exit code 0

See also:

Vinish Kapoor

FoxInfotech.in is created, written, and maintained by Vinish Kapoor. It is built on WordPress, and hosted by Bluehost. Connect with Vinish on Facebook, Twitter, and GitHub.

You may also like: