Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode characters are not supported in Presto cursors #99

Open
larandvit opened this issue Jul 22, 2020 · 0 comments
Open

Unicode characters are not supported in Presto cursors #99

larandvit opened this issue Jul 22, 2020 · 0 comments

Comments

@larandvit
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant