1

I'm trying to connect to an Oracle database within a python script, I'm not allowed to use any 3rd party imports/downloads, only the python standard library, like cx_oracle, which is the only solution to this I've found. I'm not super familiar with oracle databases, could someone explain how to connect and query without using cx_oracle and things like it.

1
  • 1
    Are you asking how one interacts with an Oracle database in Python without using cx_Oracle? Incidentally, cx_Oracle is not part of the standard Python library, but it's the most commonly used Python API for interacting with Oracle. It can be used both directly, or through a higher-level API like SQLAlchemy. You're generally not going to find a way to connect to an Oracle database in Python without doing a "pip install" of some sort of database API - unless you write some really low-level code. Commented Jun 19, 2019 at 15:56

2 Answers 2

0

Sourced from the documentation:

https://cx-oracle.readthedocs.io/en/latest/installation.html#quick-start-cx-oracle-installation

Example:

import cx_Oracle

# Connect as user "hr" with password "welcome" 
# to the "oraclepdb" service running on this computer. 
connection = cx_Oracle.connect("hr", "welcome", "localhost/orclpdb")

cursor = connection.cursor() 
cursor.execute("""
    SELECT first_name, last_name
    FROM employees
    WHERE department_id = :did AND employee_id > :eid""",
    did = 50,
    eid = 190) 
for fname, lname in cursor:
    print("Values:", fname, lname)
Sign up to request clarification or add additional context in comments.

2 Comments

I'm asking how to do this without cx_Oracle. I'm not allowed to download/import anything from a 3rd party. I'm only allowed to use the python standard library
We are not going to discuss how nonsense some cyber security control blocking staff from downloading cx_oracle. Ppl come to this pages to find work around
0

Oracle's network protocol isn't public so you need either (i) some Oracle technology installed on your computer that knows that protocol - this is cx_Oracle and Oracle Instant Client (ii) or something like Oracle's ORDS product running on the database which will let you use REST calls.

If you need to interact with an Oracle Database you could make a very strong argument that you need to install cx_Oracle and Oracle Instant Client. cx_Oracle is on PyPI so it can be installed like any other Python package you need. Instant Client needs to be installed separately, but is the Oracle product that you could be expected to require to connect to Oracle DB.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.