prestodb / presto-python-client

Python DB-API client for Presto

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unicode characters are not supported in Presto cursors

larandvit opened this issue · comments

Hello,

It seems Unicode characters are not supported in cursors. When a Presto table has Unicode characters, UnicodeEncodeError error comes up during retrieval of cursor values. cp1252 encoding is applied. Is there any setting to apply utf-8 encoding?

Error message

Traceback (most recent call last):
  File "C:\\Code\prestodb_stats.py", line 146, in <module>
    print(field)
  File "C:\Program Files\Python36\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\uffe5' in position 0: character maps to <undefined>

Code

conn = prestodb.dbapi.connect(**con_config)
cur = conn.cursor()
cur.execute(sql_text)
rows = cur.fetchall()

for row in rows:
      for field in row:
           print(field)

For example, Unicode value is .

Thank you.