mamafoku
mamafoku

Reputation: 1139

SAS to Python - Remote Access to Oracle database

I understand how to connect remotely to Oracle database in python:

import cx_Oracle
connstr = 'Oracle_Username/Oracle_Password@IP_Address:Port/Instance'
conn = cx_Oracle.connect(connstr)

However I have SAS scripts and want to mimic the same procedure in Python but am struggling to understand the role of path and schema in the following SAS script and if it needs to be incorporated into the Python script?

libname ora oracle user=oracle-user                      
                   password=oracle-password 
                   path=oracle-path
                   schema=schema-name; 

I have read through documentation but not being familiar with SAS, it is still very vague.

Upvotes: 0

Views: 509

Answers (2)

Tom
Tom

Reputation: 51611

The PATH= option specifies the TNS entry for the Oracle database. Get your DBA to translate that for you into the syntax you need to replace the @IP_Address:Port/Instance in your connection string.

The value after USER= is what you called Oracle_Username and the value after PASSWORD= is what you called Oracle_Password.

The value of the SCHEMA= option specifies which schema in Oracle the SAS libref will use. So if the SAS code later references a dataset by the name ORA.MYTABLE then it means the table MYTABLE in the schema schema-name. In direct Oracle code you could reference that table directly as schema-name.MYTABLE.

Upvotes: 1

user8662175
user8662175

Reputation: 1

Pathname= is TNS entry configured in Oracle(sever related details are configured here) Schema= is user schema

If you are able to connect Oracle you can access any table like below

Schema_name.table_name

Upvotes: 0

Related Questions