Is there anybody who knows how to solve the next problem?
Right now I am using this code:
def databasedump(request):
# Convert file existing_db.db to SQL dump file dump.sql
con = sqlite3.connect('database.sqlite')
with open('dump.sql', 'w') as f:
for line in con.iterdump():
f.write('%s\n' % line)
and I get this error:
Exception Type:
UnicodeEncodeErrorException Value:
‘ascii’ codec can’t encode character u’\xe9′ in position 112: ordinal not in range(128)
The string that could not be encoded/decoded was: (Arivé, PAK
Thanks for looking into this!
There is a bug in the
sqlite3dump code, tracked as issue 15019 in the Python bug tracker.You can fix this by editing the
sqlite3/dump.pyfile and adding the following line at the top:Locate the file by running the following command:
You’ll have to adjust the line writing code to encode the unicode values that now will be returned from the
.iterdump()method:If you feel uncomfortable with editing the Python standard library source files, use the following (fixed and shortened) function instead:
Use the above like this: