<?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: How to store SQL query result data on a local disk? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13308#M8009</link>
    <description>&lt;P&gt;No, I am not using AWS. I am using Azure and want to download SQL results to the local drive. your above post not helpful&lt;/P&gt;</description>
    <pubDate>Sat, 16 Jul 2022 18:07:44 GMT</pubDate>
    <dc:creator>DipakBachhav</dc:creator>
    <dc:date>2022-07-16T18:07:44Z</dc:date>
    <item>
      <title>How to store SQL query result data on a local disk?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13306#M8007</link>
      <description>&lt;P&gt;I am a newbie to data bricks and trying to write results into the excel/ CSV file using the below command but getting&amp;nbsp;&lt;/P&gt;&lt;P&gt;DataFrame' object has no attribute 'to_csv'&lt;/P&gt;&lt;P&gt;&amp;nbsp;errors while executing.&lt;/P&gt;&lt;P&gt;I am using a notebook to execute my SQL queries and now want to store results in the CSV or excel file&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%python
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
df =spark.sql ("""select * from customer""") &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and now I want to store the query results in the excel/csv file.I have tried the below code but it's not working&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.coalesce(1).write.option("header","true").option("sep",",").mode("overwrite").csv("file:///C:/New folder/mycsv.csv")      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.write.option("header", "true").csv("file:///C:/New folder/mycsv.csv")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 21:57:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13306#M8007</guid>
      <dc:creator>DipakBachhav</dc:creator>
      <dc:date>2022-07-15T21:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to store SQL query result data on a local disk?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13307#M8008</link>
      <description>&lt;P&gt;Are you using Databricks on AWS, Azure or GCP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If AWS, then you need to create an S3 bucket and mount that S3 bucket on dbfs location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm assuming that customer table exists in your databricks account.&lt;/P&gt;&lt;P&gt;Next, run this code and it will write your df to S3 location. &lt;/P&gt;&lt;P&gt;Lastly, download the csv file from your S3 location to local.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df = spark.sql("select * from customers")
df.write.option("header",true).csv(&amp;lt;dbfs_path&amp;gt;)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;More about dbfs: &lt;A href="https://docs.databricks.com/data/databricks-file-system.html" alt="https://docs.databricks.com/data/databricks-file-system.html" target="_blank"&gt;here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 03:02:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13307#M8008</guid>
      <dc:creator>AmanSehgal</dc:creator>
      <dc:date>2022-07-16T03:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to store SQL query result data on a local disk?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13308#M8009</link>
      <description>&lt;P&gt;No, I am not using AWS. I am using Azure and want to download SQL results to the local drive. your above post not helpful&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 18:07:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13308#M8009</guid>
      <dc:creator>DipakBachhav</dc:creator>
      <dc:date>2022-07-16T18:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to store SQL query result data on a local disk?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13309#M8010</link>
      <description>&lt;P&gt;Use “download query results” in your DBSQL or notebook cell to download to local disk. &lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 15:28:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13309#M8010</guid>
      <dc:creator>axb0</dc:creator>
      <dc:date>2022-07-17T15:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to store SQL query result data on a local disk?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13310#M8011</link>
      <description>&lt;P&gt;If your query results are upto 1000 records, then you can download from the cell.. for more than that you'll have to write it to your cloud storage and then download from there.. Else you can run query in batches of 1000 to download it..&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 23:51:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13310#M8011</guid>
      <dc:creator>AmanSehgal</dc:creator>
      <dc:date>2022-07-17T23:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to store SQL query result data on a local disk?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13311#M8012</link>
      <description>&lt;P&gt;Hi there @Dipak Bachhav​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 08:23:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-store-sql-query-result-data-on-a-local-disk/m-p/13311#M8012</guid>
      <dc:creator>Vidula</dc:creator>
      <dc:date>2022-09-05T08:23:07Z</dc:date>
    </item>
  </channel>
</rss>

