sql2csv mysql UnicodeDecodeError
Created by: sanderm
$ sql2csv --db mysql://username:password@localhost/dbname' --query "select 'ø'"
gives:
Your file is not "utf-8" encoded. Please specify the correct encoding with the -e flag. Use the -v flag to see the complete error.
When I try with -v I get the compleate error message:
$ sql2csv -v --db mysql://username:password@localhost/dbname' --query "select 'ø'"
gives:
Traceback (most recent call last):
File "/usr/local/bin/sql2csv", line 9, in <module>
load_entry_point('csvkit==1.0.0', 'console_scripts', 'sql2csv')()
File "build/bdist.linux-x86_64/egg/csvkit/utilities/sql2csv.py", line 64, in launch_new_instance
File "build/bdist.linux-x86_64/egg/csvkit/utilities/sql2csv.py", line 58, in main
File "build/bdist.linux-x86_64/egg/csvkit/py2.py", line 46, in writerow
File "build/bdist.linux-x86_64/egg/csvkit/unicsv.py", line 90, in writerow
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
$ echo $LANG en_US.UTF-8
but when I try with the sqllite driver, then it works:
$ sql2csv -v --db "sqlite:///dummy.db" --query "select 'ø'" 'ø' ø