Set Up Python
You need to install the python-oracledb driver to successfully configure a connection to a TimesTen database in Python.
Task 1: Install the python-oracledb Driver
There are several approaches for installing the python-oracledb driver. Choose the approach that is most suitable for your setup and environment.
-
Install the python-oracledb driver from PyPI. See Quick Start python-oracledb Installation.
- Install the python-oracledb driver from source code. You can either perform the installation using GitHub, opensource.oracle.com, or PyPI. See Installing from Source Code.
-
Install the python-oracledb driver without Internet access. See Installing python-oracledb without Internet Access.
Information for all scenarios is available at Installing python-oracledb.
Task 2: Initialize the python-oracledb Driver
To enable Thick mode for the python-oracledb driver, call the
oracledb.init_oracle_client()
function in your application before
creating any connection. See Enabling python-oracledb Thick
mode.
This calls the oracledb.init_oracle_client()
function
without a lib_dir
parameter to ensure it uses the PATH
environment variable set by ttenv
script. See Task 2: Set the TimesTen Environment.
import oracledb
oracledb.init_oracle_client()
Task 3: Configure Connections to TimesTen in Python
This example uses a TNS name for a Python connection string:
connection = oracledb.connect(user="appuser", password="password", dsn="sampledbconn")
This example uses an Easy Connect string that specifies a direct connection to TimesTen:
connection = oracledb.connect(user="appuser", password="password", dsn="myhost/sampledb:timesten_direct")