Open caitinggui opened 6 years ago
Ideally, yes. If you have the name of the database configured in the configuration-file, you only have to append the name with '?charset=utf8'.
So, for example:
DATABASE=sqlite:////<path to your project>/dashboard.db
becomes
DATABASE=sqlite:////<path to your project>/dashboard.db?charset=utf8
Let me know if this works..
Patrick
Sorry, it can't work:
File "/home/hadoop/project/lawplatform/env/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 477, in __init__
connection = pool._invoke_creator(self)
File "/home/hadoop/project/lawplatform/env/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 106, in connect
self.__connect(first_connect_check=True)
File "/home/hadoop/project/lawplatform/env/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 671, in __connect
connection = pool._invoke_creator(self)
File "/home/hadoop/project/lawplatform/env/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 106, in connect
return dialect.connect(*cargs, **cparams)
return dialect.connect(*cargs, **cparams)
File "/home/hadoop/project/lawplatform/env/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 410, in connect
return self.dbapi.connect(*cargs, **cparams)
TypeError: 'charset' is an invalid keyword argument for this function
I use engine.connect().connection.text_factory = str
in flask_monitoringdashboard/database/__init__.py
, and this can help. But I don't know if it will affect other databases like MySQL and so on.
Reference links in stackoverflow: SQLite3 : You must not use 8-bit bytestrings unless you use a text_factory sqlalchemy - (ProgrammingError) can interpret 8-bit bytestrings
We just released a new major version, 2.0.0 in #164. Let us know if you still get the issue in the new version.
@bogdanp05 sorry, I still get the issue in the new version. Flask-MonitoringDashboard==2.0.0
log:
So, should we specifying utf-8 encoding when connect to sqlite3 with sqlalchemy?