I am trying to do a SQL dump of a table to excel but I can't get past the error, what am I doing wrong?
Error line 14
'utf8' codec can't decode byte 0xc3 in position 0: invalid continuation byte
<SPAN class="keyword token">import</SPAN> pyodbc
<SPAN class="keyword token">import</SPAN> pandas <SPAN class="keyword token">as</SPAN> pd
<SPAN class="keyword token">import</SPAN> os
cnxn <SPAN class="operator token">=</SPAN> pyodbc<SPAN class="punctuation token">.</SPAN>connect<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Driver={SQL Server};"</SPAN>
<SPAN class="string token">"Server=***;"</SPAN>
<SPAN class="string token">"Database=***;"</SPAN>
<SPAN class="string token">"uid=***;pwd=***"</SPAN><SPAN class="punctuation token">)</SPAN>
cursor <SPAN class="operator token">=</SPAN> cnxn<SPAN class="punctuation token">.</SPAN>cursor<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
script <SPAN class="operator token">=</SPAN> <SPAN class="string token">"""
SELECT * FROM ***.***
"""</SPAN>
df <SPAN class="operator token">=</SPAN> pd<SPAN class="punctuation token">.</SPAN>read_sql<SPAN class="punctuation token">(</SPAN>script<SPAN class="punctuation token">,</SPAN> cnxn<SPAN class="punctuation token">)</SPAN>
writer <SPAN class="operator token">=</SPAN> pd<SPAN class="punctuation token">.</SPAN>ExcelWriter<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">'C:\Temp\export.xlsx'</SPAN><SPAN class="punctuation token">)</SPAN>
df<SPAN class="punctuation token">.</SPAN>to_excel<SPAN class="punctuation token">(</SPAN>writer<SPAN class="punctuation token">,</SPAN> sheet_name <SPAN class="operator token">=</SPAN><SPAN class="string token">'Sheet1'</SPAN><SPAN class="punctuation token">,</SPAN> encoding<SPAN class="operator token">=</SPAN><SPAN class="string token">'utf-8'</SPAN><SPAN class="punctuation token">)</SPAN>
writer<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>