Ok, So I have a database called cars.db which has a table == inventory,
Inventory essentially contains
('Ford', 'Hiluz', 2),
('Ford', 'Tek', 6),
('Ford', 'Outlander', 9),
('Honda', 'Dualis', 3),
('Honday', 'Elantre', 4)
I then wrote this which is meant to edit that to the csv, however, I can't seem to work this out, in some cases I get stuff to print but its not right, and when I try and fix that, nothing prints. Any suggestions to get me on track?
#write table to csv
import sqlite3
import csv
with sqlite3.connect("cars.db") as connection:
csvWriter = csv.writer(open("output.csv", "w"))
c = connection.cursor()
rows = c.fetchall()
for x in rows:
csvWriter.writerows(x)