Skip to content

Unicode characters are not supported in Presto cursors #99

Open
@larandvit

Description

@larandvit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions