A minimal Python project that demonstrates how to connect to an Oracle database using the python-oracledb
driver.
-
Clone the Repository:
git clone https://github.com/apandis/python-oracledb-example.git cd python-oracledb-exampl
-
Create and Activate a Virtual Environment:
python -m venv env
- On Windows:
env\Scripts\activate
- On macOS/Linux:
source env/bin/activate
- On Windows:
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment Variables:
Create a
.env
file in the project root with the following content:DB_USER=your_username DB_PASS=your_password DB_SERVER=your_server_address DB_PORT=1521 DB_SERVICE=your_service_name
To connect to the Oracle database and execute a sample query, run:
python src/main.py
To run the tests, use:
python -m unittest discover tests