Добрый вечер.
Бьюсь который час над проблемой:
...
DB = MySQLdb.connect(host="localhost", user="root", passwd="123", db="123", charset='utf8')
...
Cursor = DB.cursor()
delimiter = ';'
csv_data = codecs.open('tmp/' + item, 'rb', encoding='utf-8')
next(csv_data)
for line in csv_data:
print line
row = line.split(delimiter)
print row
Cursor.execute('INSERT INTO cdr(device_id, connection_date_time, call_duration, call_disconnection_cause, \
call_information, a_ip, a_type, a_name, a_number, a_mod_number, b_ip, b_type, b_name, b_number, b_mod_number, \
incoming_date_time, disconnection_date_time, SMS) VALUES("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", \
"%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")', row)
DB.commit()
Получаю в ответ:
Traceback (most recent call last):
File "C:/Users/�������/PycharmProjects/untitled/download_files.py", line 109, in
"%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")', row)
File "H:\Developer\python2\lib\site-packages\MySQLdb\cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "H:\Developer\python2\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1366, "Incorrect string value: '\\xD0\\x9C\\xD0\\xB0\\xD1\\x88...' for column 'a_name' at row 1")
Собственно вопрос - как это победить?