How can I insert a pandas DataFrame into Azure SQL Database with JDBC?

Jeff vG 96 Reputation points
2021-07-25T13:19:02.12+00:00

What is the correct way to use the JDBC Spark modules to insert a 4k row pandas DataFrame into Azure SQL Server? I see many questions like this on StackOverflow, but the answers are generally "it can't be done" or are overly complicated. It's difficult to believe that this is not a core use case of Azure Databricks.

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,514 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. PRADEEPCHEEKATLA 90,641 Reputation points Moderator
    2021-07-26T09:02:09.387+00:00

    Hi @Jeff vG ,

    Thanks for the question and using MS Q&A platform.

    Looks like you cannot insert a pandas DataFrame into Azure SQL Database using JDBC.

    When I tried using JDBC it returns - Query returned no results.

    I would suggest try using the pyodbc package.

    117808-image.png

    This article - Insert Python dataframe into SQL table describes how to insert a pandas dataframe into a SQL database using the pyodbc package in Python.

    Hope this helps. Do let us know if you any further queries.

    ---------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.