F.Peconi
F.Peconi

Reputation: 56

Connect to Oracle from Spark using Oracle's Wallet

I would like to secure an Oracle connection with PySpark using Oracle's Wallet.

As for now, I am hardcoding the credentials and performing a working connection with the following:

    # Connection properties
    driver='oracle.jdbc.driver.OracleDriver'
    connString='jdbc:oracle:thin:@1.1.1.1.sample/SID'
    user='user'
    pwd='pwd' 
    jdbc_dict = {'driver':driver, 
               'connection':connString, 
               'user':user, 
               'pwd':pwd }
    
    df_table = spark.read.format('jdbc')\
                    .option('driver',jdbc_dict['driver'])\
                    .option('url',jdbc_dict['connection'])\
                    .option('dbtable',table_name)\
                    .option('user',jdbc_dict['user'])\
                    .option('password',jdbc_dict['pwd']).load()

Now, I am moving to another environment and want to get rid of credentials from the code.

Assuming that I have correctly created a Wallet on my client, how do I change the previously shown code to get it working with the Wallet?

I believe I have to point at the Wallet's path in some way but couldn't find any proper documentation regarding Spark, more precisely, PySpark.

Upvotes: 0

Views: 1203

Answers (1)

Georg Heiler
Georg Heiler

Reputation: 17724

Use yarn with the -- files parameter in yarn Cluster mode to copy the wallet to your nodes. And then simply read it as an local file path

Upvotes: 0

Related Questions