question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dashboard filter error - 'ascii' codec can't encode character

See original GitHub issue

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven’t found one similar

Superset version

{“GIT_SHA”: “”, “version”: “0.17.2”}

Expected results

Filtering the table without errors

Actual results

'ascii' codec can't encode character u'\u0406' in position 1512: ordinal not in range(128)

in terminal

2017-03-31 13:40:17,476:ERROR:root:'ascii' codec can't encode character u'\u0406' in position 1512: ordinal not in range(128)
Traceback (most recent call last):
  File "/data/work/virtualenvs/superset/lib/python2.7/site-packages/superset/viz.py", line 234, in get_payload
    df = self.get_df()
  File "/data/work/virtualenvs/superset/lib/python2.7/site-packages/superset/viz.py", line 78, in get_df
    self.results = self.datasource.query(query_obj)
  File "/data/work/virtualenvs/superset/lib/python2.7/site-packages/superset/connectors/sqla/models.py", line 536, in query
    sql = self.get_query_str(**query_obj)
  File "/data/work/virtualenvs/superset/lib/python2.7/site-packages/superset/connectors/sqla/models.py", line 318, in get_query_str
    compile_kwargs={"literal_binds": True}
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0406' in position 1512: ordinal not in range(128)
2017-03-31 13:40:17,479:INFO:root:Caching for the next 86400 seconds

Steps to reproduce

default

After selecting a filter

default

Thank you

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
xrmxcommented, Apr 11, 2017

This should fix the issue and doesn’t break tests here:

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 903182de..1a2bc37e 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -3,6 +3,7 @@ import logging
 import sqlparse
 
 import pandas as pd
+import six
 
 from sqlalchemy import (
     Column, Integer, String, ForeignKey, Text, Boolean,
@@ -315,7 +316,7 @@ class SqlaTable(Model, BaseDatasource):
     def get_query_str(self, **kwargs):
         engine = self.database.get_sqla_engine()
         qry = self.get_sqla_query(**kwargs)
-        sql = str(
+        sql = six.text_type(
             qry.compile(
                 engine,
                 compile_kwargs={"literal_binds": True}
1reaction
mistercrunchcommented, Apr 11, 2017

If this is a mysql query try appending ?charset=utf8 to your SQLAlchemy URI

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dashboard filter error - 'ascii' codec can't encode character ...
I get the same error when open the menu "Security --> List Roles". ... I had some charts and a Dashboard containing the...
Read more >
Fix Python UnicodeEncodeError: 'ascii' codec can't encode ...
How to Fix UnicodeEncodeError: 'ascii' codec can't encode character in Python and when writing pandas DataFrames to CSV files.
Read more >
'ascii' codec can't encode character (#313) · Issues - GitLab
Hello! PETSc-3.11.2's configure is failing with this error: 'ascii' codec can't encode character '\u2018' in position 72: ordinal not in range( ...
Read more >
Bug #1472999 “filter doesn't handle unicode charaters”
1 go to project/instances 2. insert 'ölk' into filter field 3. enter filter 4. UnicodeEncodeError at /project/instances/ 'ascii' codec can't ...
Read more >
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc'
Hello,. I'm using german umlauts for description and summary field. If I have german umlaut I got the error above. I changed code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found