Accessing Oracle with Python

Ubuntu 14.04
$ sudo apt-get install python-dev
$ sudo pip install --upgrade pip
$ sudo -H pip install JayDeBeApi
Refer: https://pypi.org/project/JayDeBeApi/
Another option, untried: http://cx-oracle.readthedocs.io/en/latest/installation.html#quick-start-cx-oracle-installation

Docker Oracle Client

$ docker pull store/oracle/database-instantclient:12.2.0.1

Refer: https://store.docker.com/profiles/mruckman/content/sub-e067a44b-9ead-41c7-b597-de06ee2ef454

About this Docker Image

This Docker image contains the Oracle Instant Client 'Basic', 'SDK' and 'SQL*Plus' packages. It can be extended to run OCI, OCCI, and JDBC applications. It can also be extended to build and run scripting language drivers that use OCI such as Python's cx_Oracle, Node.js's node-oracledb, PHP's OCI8, and Ruby's ruby-oci8.

The SQL*Plus command-line query tool is also included, allowing quick ad-hoc SQL and PL/SQL execution.

About Oracle Instant Client

Oracle Instant Client is a repackaging of Oracle Database libraries, tools and header files usable to create and run applications that connect to a remote (or local) Oracle Database.

Usage

You can run a container interactively to execute ad-hoc SQL and PL/SQL statements in SQL*Plus:

docker run -ti --rm store/oracle/database-instantclient:12.2.0.1 sqlplus hr/welcome@example.com/pdborcl

Adding Oracle Database Drivers

To extend the image with optional Oracle Database drivers, follow your desired driver installation steps. The Instant Client libraries are in /usr/lib/oracle/12.2/client64/lib and the Instant Client headers are in /usr/include/oracle/12.2/client64/.

The Instant Client libraries are in the default library search path.

Install SQL*Plus on MacBook

Refer: https://tomeuwork.wordpress.com/2014/05/12/how-to-install-oracle-sqlplus-and-oracle-client-in-mac-os/
Refer: https://halpjira01.flagship.hal.com:9443/confluence/pages/viewpage.action?pageId=46664178

Instructions for this setup were taken from this blog post and massaged to reflect the current version number of the Oracle application.

Download the following two files from the Oracle website: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

"Instant Client Package - Basic"
"Instant Client Package - SQL*Plus"
Extract the files and create the proper directory structure

Open the terminal and unzip the downloaded files
$ unzip -qq instantclient-basic-macos.x64-12.1.0.2.0.zip
$ unzip -qq instantclient-sqlplus-macos.x64-12.1.0.2.0.zip
These will be extracted into a single directory: instantclient_12_1

Create the expected directory structure
$ mkdir -p /Applications/oracle/product/instantclient_64/12.1.0.2.0/{bin,lib,jdbc/lib,rdbms/jlib,sqlplus/admin,network/admin}

Transfer files over to the new directory
$ ORACLE=/Applications/oracle/product/instantclient_64/12.1.0.2.0
mv ojdbc* $ORACLE/jdbc/lib/
mv x*.jar $ORACLE/rdbms/jlib
mv glogin.sql $ORACLE/sqlplus/admin
mv *dylib* $ORACLE/lib/
mv *README $ORACLE
mv ./* $ORACLE/bin/

Add tnsnames.ora to /Applications/oracle/product/instantclient_64/12.1.0.2.0/network/admin/
You should be able to get this file from another dev

Set up the environment variables
$ cd ~ && vi ~/.bash_profile

Add the following exports to .bash_profile
export ORACLE_HOME=/Applications/oracle/product/instantclient_64/12.1.0.2.0
export PATH=$ORACLE_HOME/bin:$PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib

Update .bash_profile
$ source ~/.bash_profile

After all that, you should now be able to run SQL*Plus from the command line.