I am having issues with the following export from sql table to csv. the output file is creating a extra line between each row, i need to resolve this. to include the headers and rows without extra line
import pyodbc
import csv
conn = pyodbc. connect("Driver ={sql native client};"
"server =myserver;
"Database = testdb;"
"trusted connection = yes")]
cursor = conn.cursor
sql1 = """select * from mytable"
cursor.execute(sql1)
with open('c:/test/myfile.csv', 'w')as output
writer = csv.writer(output)
writer.writerow(col[0] for col in cursor.description)
for row in cursor:
writer.writerow(row)
cursor.close()
