# -*- coding: utf-8 -*-
import MySQLdb
db = MySQLdb.connect(host=“localhost”, user=“root”, passwd=“могилев”, db=“my_test_db”, charset='utf8')
cursor = db.cursor()
sql=“create table if not exists %s (test_column VARCHAR(128));” %(u“тест”.encode(“utf-8”))
cursor.execute(sql)
db.commit
При первом запуске скрипта создается таблица
при последующих запусках выдает следующую ошибку:
UnicodeEncodeError: ‘ascii’ codec can't encode characters in position 7-10: ordinal not in range(128)
Помогите, что не так?