Synapse Notebook - Read Data From Oracle DB

NPizzuti 51 Reputation points

Has anybody read data into a Synapse notebook (Python, pyspark) from an Oracle data source? I've tried getting the correct JDBC driver as a .jar, but adding it as a library does not work. I've also tried going the pyODBC route, but I consistently get login timeouts.

If anybody can point me in the right direction, I would appreciate it.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,330 questions
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 30,361 Reputation points Microsoft Employee

    Hi @NPizzuti ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your question.

    In order to read data from oracle DB using Pyspark inside synapse notebook, kindly try adding the .jar here (ojdbc8- to the Synapse workspace packages and then adding that package to the Apache spark pool (to know more about this process kindly check this video) and execute the following code:

    host = 'my_host_url'  
    port = 1521  
    service_name = 'my_service_name'  
    jdbcUrl = f'jdbc:oracle:thin:@{host}:{port}:{service_name}'  
    sql = 'SELECT * FROM my_table'  
    user = 'my_username'  
    password = 'my_password'  
    jdbcDriver = 'oracle.jdbc.driver.OracleDriver'  
    jdbcDF ='jdbc') \  
        .option('url', jdbcUrl) \  
        .option('query', sql) \  
        .option('user', user) \  
        .option('password', password) \  
        .option('driver', jdbcDriver) \  

    Hope this will help. Please let us know if any further queries.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

0 additional answers

Sort by: Most helpful