<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Send UPDATE from Databricks to Azure SQL DataBase in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27204#M19084</link>
    <description>&lt;P&gt;This is &lt;A href="https://stackoverflow.com/questions/54345110/how-to-update-a-azure-sql-database-data-warehouse-table-by-azure-databricks" alt="https://stackoverflow.com/questions/54345110/how-to-update-a-azure-sql-database-data-warehouse-table-by-azure-databricks" target="_blank"&gt;discussed on Stack Overflow&lt;/A&gt;. As you see for Azure Synapse there is a way, but for a plain SQL database you will have to use some kind of driver like odbc/jdbc.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Feb 2022 07:42:44 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2022-02-24T07:42:44Z</dc:date>
    <item>
      <title>Send UPDATE from Databricks to Azure SQL DataBase</title>
      <link>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27202#M19082</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to know how to do an UPDATE on Azure SQL DataBase from Azure Databricks using PySpark.&lt;/P&gt;&lt;P&gt;I know how to make query as SELECT and turn it into DataFrame, but how to send back some data (as UPDATE on rows)?&lt;/P&gt;&lt;P&gt;I want to use build in pyspark istead of some pyodbc or something else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Łukasz&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 11:32:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27202#M19082</guid>
      <dc:creator>LukaszJ</dc:creator>
      <dc:date>2022-02-23T11:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Send UPDATE from Databricks to Azure SQL DataBase</title>
      <link>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27204#M19084</link>
      <description>&lt;P&gt;This is &lt;A href="https://stackoverflow.com/questions/54345110/how-to-update-a-azure-sql-database-data-warehouse-table-by-azure-databricks" alt="https://stackoverflow.com/questions/54345110/how-to-update-a-azure-sql-database-data-warehouse-table-by-azure-databricks" target="_blank"&gt;discussed on Stack Overflow&lt;/A&gt;. As you see for Azure Synapse there is a way, but for a plain SQL database you will have to use some kind of driver like odbc/jdbc.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 07:42:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27204#M19084</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-02-24T07:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Send UPDATE from Databricks to Azure SQL DataBase</title>
      <link>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27205#M19085</link>
      <description>&lt;P&gt;Hello werners,&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In &lt;A href="https://stackoverflow.com/questions/54345110/how-to-update-a-azure-sql-database-data-warehouse-table-by-azure-databricks" alt="https://stackoverflow.com/questions/54345110/how-to-update-a-azure-sql-database-data-warehouse-table-by-azure-databricks" target="_blank"&gt;your link&lt;/A&gt; I found &lt;A href="https://docs.databricks.com/data/data-sources/azure/synapse-analytics.html#language-python" alt="https://docs.databricks.com/data/data-sources/azure/synapse-analytics.html#language-python" target="_blank"&gt;this link&lt;/A&gt;, where is this peace of code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;# Load data from an Azure Synapse query.
df = spark.read \
[...]
&amp;nbsp;
# Apply some transformations to the data, then use the
# Data Source API to write the data back to another table in Azure Synapse.
&amp;nbsp;
df.write \
  .format("com.databricks.spark.sqldw") \
  .option("url", "jdbc:sqlserver://&amp;lt;the-rest-of-the-connection-string&amp;gt;") \
  .option("forwardSparkAzureStorageCredentials", "true") \
  .option("dbTable", "&amp;lt;your-table-name&amp;gt;") \
  .option("tempDir", "wasbs://&amp;lt;your-container-name&amp;gt;@&amp;lt;your-storage-account-name&amp;gt;.blob.core.windows.net/&amp;lt;your-directory-name&amp;gt;") \
  .save()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, it is not a good solution for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all, what if I want to update one row in the table that has a few milions records?&lt;/P&gt;&lt;P&gt;Do I need to download the entire table into dataframe, update one row and resend to Azure SQL? It looks really ineffective.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover, what if I want to make update on table which has an auto-indexing column? I cannot download the table to a dataframe, update with my own id value, and resend to Azure SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is why I am using PyOdbc now, because I can make real sql insert / update.&lt;/P&gt;&lt;P&gt;Is there any elegant solution at Databricks?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Łukasz&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 08:07:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27205#M19085</guid>
      <dc:creator>LukaszJ</dc:creator>
      <dc:date>2022-02-25T08:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Send UPDATE from Databricks to Azure SQL DataBase</title>
      <link>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27206#M19086</link>
      <description>&lt;P&gt;The code you mention is for Azure Synapse.  If you want to use plain Azure SQL, your options are limited.&lt;/P&gt;&lt;P&gt;You can &lt;A href="https://docs.microsoft.com/en-us/azure/databricks/data/data-sources/sql-databases" alt="https://docs.microsoft.com/en-us/azure/databricks/data/data-sources/sql-databases" target="_blank"&gt;use JDBC&lt;/A&gt;, but there is no update functionality.&lt;/P&gt;&lt;P&gt;Or you can use the &lt;A href="https://docs.microsoft.com/en-us/azure/databricks/data/data-sources/sql-databases" alt="https://docs.microsoft.com/en-us/azure/databricks/data/data-sources/sql-databases" target="_blank"&gt;optimized spark connector&lt;/A&gt;, but that lacks DML support:&lt;/P&gt;&lt;P&gt;&lt;I&gt;Executing custom SQL through the connector&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;The previous Azure SQL Connector for Spark provided the ability to execute custom SQL code like DML or DDL statements through the connector. This functionality is out-of-scope of this connector since it is based on the DataSource APIs. This functionality is readily provided by libraries like pyodbc or you can use the standard java sql interfaces as well.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 08:39:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27206#M19086</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-02-25T08:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Send UPDATE from Databricks to Azure SQL DataBase</title>
      <link>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27207#M19087</link>
      <description>&lt;P&gt;This is the information I needed.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Łukasz&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 08:38:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-update-from-databricks-to-azure-sql-database/m-p/27207#M19087</guid>
      <dc:creator>LukaszJ</dc:creator>
      <dc:date>2022-02-26T08:38:26Z</dc:date>
    </item>
  </channel>
</rss>

