I have accessed a database and have the result in a cursor object. when I try to save it to a text file, python says
TypeError: argument 1 must be string or read-only character buffer, not sqlite3.Cursor
can someone tell me what I should do here?
curobject.execute('select * from device_auth')
for row in curobject:
print row
myfile =open('out.txt', 'w')
myfile.write(curobject)
You can’t just write objects to a file, you have to either serialize them or write your own string representation of the object. For records of a database the csv module could make sense.
Which approach is better depends on what you want to do with the file later.