Oracle Connection¶
The Oracle connection type provides connection to a Oracle database.
Configuring the Connection¶
- Dsn (required)
The Data Source Name. The host address for the Oracle server.
- Host(optional)
Connect descriptor string for the data source name.
- Sid (optional)
The Oracle System ID. The uniquely identify a particular database on a system.
- Service_name (optional)
The db_unique_name of the database.
- Port (optional)
The port for the Oracle server, Default
1521
.- Login (required)
Specify the user name to connect.
- Password (required)
Specify the password to connect.
- Extra (optional)
Specify the extra parameters (as json dictionary) that can be used in Oracle connection. The following parameters are supported:
encoding
- The encoding to use for regular database strings. If not specified, the environment variableNLS_LANG
is used. If the environment variableNLS_LANG
is not set,ASCII
is used.nencoding
- The encoding to use for national character set database strings. If not specified, the environment variableNLS_NCHAR
is used. If the environment variableNLS_NCHAR
is not used, the environment variableNLS_LANG
is used instead, and if the environment variableNLS_LANG
is not set,ASCII
is used.threaded
- Whether or not Oracle should wrap accesses to connections with a mutex. Default value is False.events
- Whether or not to initialize Oracle in events mode.mode
- one ofsysdba
,sysasm
,sysoper
,sysbkp
,sysdgd
,syskmt
orsysrac
which are defined at the module level, Default mode is connecting.purity
- one ofnew
,self
,default
. Specify the session acquired from the pool. configuration parameter.
Connect using Dsn and Sid, Dsn and Service_name, or only Host (OracleHook.getconn Documentation).
For example:
Host = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orclpdb1)))"
or
Dsn = "dbhost.example.com" Service_name = "orclpdb1"
or
Dsn = "dbhost.example.com" Sid = "orcl"
More details on all Oracle connect parameters supported can be found in cx_Oracle documentation.
Information on creating an Oracle Connection through the web user interface can be found in Airflow's Managing Connections Documentation.
Example "extras" field:
{ "encoding": "UTF-8", "nencoding": "UTF-8", "threaded": false, "events": false, "mode": "sysdba", "purity": "new" }
When specifying the connection as URI (in
AIRFLOW_CONN_{CONN_ID}
variable) you should specify it following the standard syntax of DB connections, where extras are passed as parameters of the URI (note that all components of the URI should be URL-encoded).For example:
export AIRFLOW_CONN_ORACLE_DEFAULT='oracle://oracle_user:XXXXXXXXXXXX@1.1.1.1:1521?encoding=UTF-8&nencoding=UTF-8&threaded=False&events=False&mode=sysdba&purity=new'