I am trying to export a sqlite table to a text file, and I found excellent help on this site. It works great for small exits, but as soon as I reached around 20,000, it seems to limit the output.
first try:
Mark Bells UniCodeWriter found in Can I export sqlite3 table to csv table or similar?
There are 15 columns in my table that I just listed here 5 to make it easier to read
writer = UnicodeWriter(open("Export8.csv", "wb")) writer.writerow(["RunID","JobNumber","StartTime","EndTime","Period"]) writer.writerows(results)
Second attempt:
response = cursor.execute("SELECT RunID, JobNumber, StartTime, EndTime, strftime('%s',substr(endtime,1,19)) - strftime('%s',substr(starttime,1,19)) FROM tblTest WHERE RunID <>0") strfile = open('_output1.csv','wb') for row in response: print >> strfile,row
Third attempt:
strfile = open('_output3.csv','wb') while True: row = cursor.fetchone() if row == None: break print >> strfile,row enter code here
4th attempt / test:
response = cursor.execute("SELECT RunID, JobNumber, StartTime, EndTime, Period FROM tblTest WHERE RunID <>0") print response
Result
In attempt 1: I get output from 183 complete records and the very first column of record 184
In attempt 2 and 3: I get output from 181 complete records and some 182 columns
In attempt 4: I get all my data on the screen
When I check the sqlite database, I see 205 records. I know that I can just output 100 lines at a time, but I wonder why I donβt get all my lines issued