I'm trying to do automatic alter table - adding column when it is necessary. The problem is that I've started to getting UnicodeDecodeError.
I don't understand why this error is raising. Why it wants to use 'ascii' charset.
I've tried to print attr.__class__ which prints unicode.
I've already tried to attr.decode('utf-8') but still the same problem is raising.
LINE:
self.cur.execute("""ALTER TABLE data ADD COLUMN {} TEXT""".format(attr))
RETURNS:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u010d' in position 5: ordinal not in range(128)
I have # -*- coding: utf-8 -*- on the top of the file.
What should I do in this case? Is it possible to find out which encoding is used?
EDIT: If I rewrite the alter not to use variables, it works.