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

[SQL Lab] (sqlite3.ProgrammingError) #3550

Closed
3 tasks done
15310944349 opened this issue Sep 29, 2017 · 12 comments
Closed
3 tasks done

[SQL Lab] (sqlite3.ProgrammingError) #3550

15310944349 opened this issue Sep 29, 2017 · 12 comments
Labels
inactive Inactive for >= 30 days sqllab Namespace | Anything related to the SQL Lab

Comments

@15310944349
Copy link

15310944349 commented Sep 29, 2017

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

Superset 0.19.1

Expected results

get results data from remote mysql server

Actual results

ProgrammingError: (sqlite3.ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. [SQL: u'UPDATE "query" SET tmp_table_name=?, status=?, error_message=?, changed_on=? WHERE "query".id = ?'] [parameters: (None, u'failed', "unsupported format character '\xe5' (0xffffffe5) at index 74", '2017-09-29 08:06:59.720489', 559)]

Steps to reproduce

run the fllowing sql from sql editor:
SELECT t_tm_article_id,title,subscribe_id FROM t_article WHERE title like '%品牌刀具%' limit 1'

@15310944349 15310944349 changed the title (sqlite3.ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings (sqlite3.ProgrammingError) Sep 29, 2017
@xrmx
Copy link
Contributor

xrmx commented Sep 29, 2017

Which version of python is this?

@15310944349
Copy link
Author

@xrmx Python 2.7.9

@xrmx
Copy link
Contributor

xrmx commented Oct 2, 2017

Please post the full backtrace from server logs

@15310944349
Copy link
Author

15310944349 commented Oct 4, 2017

@xrmx

Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 734, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 476, in format
    s = self._fmt % record.__dict__
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 30: invalid continuation byte
Logged from file sql_lab.py, line 192
2017-10-04 12:02:37,550:ERROR:root:(sqlite3.ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. [SQL: u'UPDATE "query" SET tmp_table_name=?, status=?, error_message=?, changed_on=? WHERE "query".id = ?'] [parameters: (None, u'failed', "unsupported format character '\xe5' (0xffffffe5) at index 74", '2017-10-04 04:02:37.549254', 768)]
Traceback (most recent call last):
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 91, in get_sql_results
    ctask, query_id, return_results, store_results)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 194, in execute_sql
    return handle_error(db_engine_spec.extract_error_message(e))
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 120, in handle_error
    session.commit()
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 906, in commit
    self.transaction.commit()
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 461, in commit
    self._prepare_impl()
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl
    self.session.flush()
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2177, in flush
    self._flush(objects)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2297, in _flush
    transaction.rollback(_capture_exception=True)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2261, in _flush
    flush_context.execute()
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 389, in execute
    rec.execute(self)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 548, in execute
    uow
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 177, in save_obj
    mapper, table, update)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 737, in _emit_update_statements
    execute(statement, multiparams)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/data00/test_users/luobin/superset/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
ProgrammingError: (sqlite3.ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. [SQL: u'UPDATE "query" SET tmp_table_name=?, status=?, error_message=?, changed_on=? WHERE "query".id = ?'] [parameters: (None, u'failed', "unsupported format character '\xe5' (0xffffffe5) at index 74", '2017-10-04 04:02:37.549254', 768)]

@mistercrunch mistercrunch changed the title (sqlite3.ProgrammingError) [SQL Lab] (sqlite3.ProgrammingError) Oct 4, 2017
@mistercrunch mistercrunch added the sqllab Namespace | Anything related to the SQL Lab label Oct 4, 2017
@mistercrunch
Copy link
Member

I'm guessing you have unicode characters in your query?

@15310944349
Copy link
Author

15310944349 commented Oct 4, 2017

@mistercrunch sql:
SELECT t_tm_article_id,title,subscribe_id FROM t_article WHERE title like '%品牌刀具%' limit 1'

@15310944349
Copy link
Author

@xrmx @mistercrunch
How to solve this problem, thx.

@mistercrunch
Copy link
Member

Have you tried python 3?

@15310944349
Copy link
Author

@mistercrunch No

@mistercrunch
Copy link
Member

Python 3 will likely take care of these unicode related issues. Also I would recommend avoiding sqlite outside of a sandbox environment. This is still a bug though.

@mistercrunch
Copy link
Member

Notice: this issue has been closed because it has been inactive for 193 days. Feel free to comment and request for this issue to be reopened.

@stale
Copy link

stale bot commented Apr 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days sqllab Namespace | Anything related to the SQL Lab
Projects
None yet
Development

No branches or pull requests

3 participants