When do insert action, if I use unicode in data field, It raise the UnicodeEncodeError, if I use str, all is well.
# python2.7
db = Medoo(dbtype="sqlite", database="test.db")
name = "foobar"
data = u"测试中文数据"
db.insert('items', {'name': name, 'data': data, 'ctime': int(time.time())})
Traceback (most recent call last):
File "test.py", line 24, in <module>
db.insert('items', {'name': name, 'data': data, 'ctime': int(time.time())})
File "C:\Python27\lib\site-packages\medoo\base.py", line 70, in insert
sql = self.builder.insert(table, fields, *values)
File "C:\Python27\lib\site-packages\medoo\builder.py", line 658, in insert
self._insert(table, values2, fields)
File "C:\Python27\lib\site-packages\medoo\builder.py", line 560, in _insert
valterms.append('({})'.format(','.join([Builder.DIALECT.value(iv) for iv in inval])))
File "C:\Python27\lib\site-packages\medoo\dialect.py", line 39, in value
return "'{}'".format(str(item).replace("'", "''"))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)
When do insert action, if I use unicode in data field, It raise the UnicodeEncodeError, if I use str, all is well.