<?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: Spark reading writing to SQL Database in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4737186#M10281</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1286298"&gt;@P_work&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As we haven't heard back from you, we are closing this thread. If you are still experiencing the issue, please feel free to create a new thread we’ll be happy to assist you further.&lt;/P&gt;
&lt;P&gt;Thank you for your patience and support.&lt;/P&gt;
&lt;P&gt;If you found our response helpful, please mark it as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Accepted Solution&lt;/STRONG&gt;&amp;nbsp;so others with similar queries can find it easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best Regards,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Lakshmi Narayana&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jun 2025 08:45:38 GMT</pubDate>
    <dc:creator>v-lgarikapat</dc:creator>
    <dc:date>2025-06-19T08:45:38Z</dc:date>
    <item>
      <title>Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4721579#M9937</link>
      <description>&lt;P&gt;The following blog post illustrates reading/writing to Fabric Warehouse from Spark notebook.&lt;/P&gt;&lt;P&gt;@https://community.fabric.microsoft.com/t5/Data-Engineering-Community-Blog/Spark-Connector-for-Fabric-Warehouse-Unified-Analytics/ba-p/4611309&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there examples to read and write to SQL Database(preview) using Spark within Fabric notebook? Say even this (currently failing):&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; df.write.jdbc(...)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 13:48:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4721579#M9937</guid>
      <dc:creator>P_work</dc:creator>
      <dc:date>2025-06-05T13:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4722057#M9942</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1286298"&gt;@P_work&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;df.write.mode("append").option("mergeSchema", "true").synapsesql("DW1.Core.CustomerData")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 21:54:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4722057#M9942</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-06-05T21:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4725204#M10012</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1286298"&gt;@P_work&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to the Microsoft fabric community forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/913195"&gt;@nilendraFabric&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your prompt response&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1286298"&gt;@P_work&lt;/a&gt;&amp;nbsp;, I have attached the official document and relevant solved threads related to your use case. I hope you find them helpful&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/spark-data-warehouse-connector?tabs=pyspark" target="_blank"&gt;Spark connector for Microsoft Fabric Data Warehouse - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Fabric-platform/Fabric-Notebook-Outputs-to-Azure-SQL-Database-or-CSV-file/m-p/3958547" target="_blank"&gt;Solved: Re: Fabric Notebook Outputs to Azure SQL Database ... - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Data-Engineering/Write-df-to-DataWarehouse-tables/m-p/4411991" target="_blank"&gt;Solved: Re: Write df to DataWarehouse tables - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helped resolve your issue, please consider giving it &lt;STRONG&gt;Kudos&lt;/STRONG&gt; and marking it as the &lt;STRONG&gt;Accepted Solution&lt;/STRONG&gt;. This not only acknowledges the support provided but also helps other community members find relevant solutions more easily.&lt;/P&gt;
&lt;P&gt;We appreciate your engagement and thank you for being an active part of the community.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best regards,&lt;BR /&gt;LakshmiNarayana&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 07:33:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4725204#M10012</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2025-06-09T07:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4728687#M10078</link>
      <description>&lt;P&gt;I believe the main issue was this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;notebookutils&lt;/SPAN&gt;&lt;SPAN&gt;.credentials.getToken(&lt;/SPAN&gt;&lt;SPAN&gt;"pbi"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The examples provided were of little use.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Also, ensuring using runtime 1.3 appeared to help.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 Jun 2025 12:34:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4728687#M10078</guid>
      <dc:creator>P_work</dc:creator>
      <dc:date>2025-06-11T12:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4730226#M10099</link>
      <description>&lt;P&gt;Here is how you connect to SQL DB from Fabric Notebook using SPN credentials&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;host = ''&lt;/DIV&gt;&lt;DIV&gt;database = ''&lt;/DIV&gt;&lt;DIV&gt;sql_query = ''&lt;/DIV&gt;&lt;DIV&gt;jdbc_url = f'jdbc:sqlserver://{host};database={database};authentication=ActiveDirectoryServicePrincipal;encrypt=true;trustServerCertificate=true;'&lt;/DIV&gt;&lt;DIV&gt;db_properties = {&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"user": f"{client_id}",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"password": f"{client_secret}",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;#For Reading&lt;/DIV&gt;&lt;DIV&gt;spark.read.jdbc(url=jdbc_url, table=f"({sql_query}) AS query_alias", properties=db_properties)&lt;BR /&gt;#For Writing data&lt;BR /&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;df&lt;/SPAN&gt;&lt;SPAN&gt;.write.jdbc(&lt;/SPAN&gt;&lt;SPAN&gt;url&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;jdbc_url&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;table&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;table_name&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;mode&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;mode&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;properties&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;db_properties&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Jun 2025 12:28:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4730226#M10099</guid>
      <dc:creator>g3kuser</dc:creator>
      <dc:date>2025-06-12T12:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4731551#M10142</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1286298"&gt;@P_work&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;If your issue has been resolved, please consider marking the most helpful reply as the &lt;STRONG&gt;accepted solution&lt;/STRONG&gt;. This helps other community members who may encounter the same issue to find answers more efficiently.&lt;/P&gt;
&lt;P&gt;If you're still facing challenges, feel free to let us know we’ll be glad to assist you further.&lt;/P&gt;
&lt;P&gt;Looking forward to your response.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best regards,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LakshmiNarayana.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 12:25:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4731551#M10142</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2025-06-13T12:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4732932#M10174</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1286298"&gt;@P_work&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your issue has been resolved, please consider marking the most helpful reply as the &lt;STRONG&gt;accepted solution&lt;/STRONG&gt;. This helps other community members who may encounter the same issue to find answers more efficiently.&lt;/P&gt;
&lt;P&gt;If you're still facing challenges, feel free to let us know we’ll be glad to assist you further.&lt;/P&gt;
&lt;P&gt;Looking forward to your response.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best regards,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LakshmiNarayana.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2025 06:53:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4732932#M10174</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2025-06-16T06:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Spark reading writing to SQL Database</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4737186#M10281</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1286298"&gt;@P_work&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As we haven't heard back from you, we are closing this thread. If you are still experiencing the issue, please feel free to create a new thread we’ll be happy to assist you further.&lt;/P&gt;
&lt;P&gt;Thank you for your patience and support.&lt;/P&gt;
&lt;P&gt;If you found our response helpful, please mark it as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Accepted Solution&lt;/STRONG&gt;&amp;nbsp;so others with similar queries can find it easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best Regards,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Lakshmi Narayana&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 08:45:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-reading-writing-to-SQL-Database/m-p/4737186#M10281</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2025-06-19T08:45:38Z</dc:date>
    </item>
  </channel>
</rss>

