I'm writing a program that opens a database file saved with pickle. but if i want to load the list from the file into the memory with StringIO/cStringIO it says:
Opening database...
Loading database into memory...
Traceback (most recent call last):
...
File "C:\myfile.py", line 17 in open_database
database.write(databasefile)
TypeError: must be string or read-only character buffer, not list
This is my code:
def open_database(self):
print("Opening database...")
databasefile = open('database.dat', "r")
databasecontent = cPickle.load(databasefile)
databasefile.close()
print('Loading database into memory...')
database = cStringIO.StringIO()
database.write(databasecontent)
atexit.register(close_database)