本文介绍了从 pgadmin4 创建数据库时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我从 pgadmin 4 创建数据库时,它总是显示错误弹出窗口:保存属性时出错.
When I create database from pgadmin 4, it always show error popup: Error saving properties.
我的电脑信息:
- Linux Mint 18.3
- pgAdmin 4 2.1 来自 https://wiki.postgresql.org/wiki/Apt
- Python 3.5.2(默认,2017 年 11 月 23 日,16:37:01)[GCC 5.4.0 20160609]
我在 pgadmin4.log 中的错误:
My error in pgadmin4.log:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
execute(self.server.app)
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 168, in execute
application_iter = app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/lib/python3/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/lib/python3/dist-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/share/pgadmin4/web/pgadmin/browser/utils.py", line 242, in dispatch_request
return method(*args, **kwargs)
File "/usr/share/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/__init__.py", line 157, in wrapped
return f(self, *args, **kwargs)
File "/usr/share/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/__init__.py", line 489, in create
data=data, conn=self.conn
File "/usr/lib/python3/dist-packages/flask/templating.py", line 128, in render_template
context, ctx.app)
File "/usr/lib/python3/dist-packages/flask/templating.py", line 110, in _render
rv = template.render(context)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/share/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/create.sql", line 10, in top-level template code
ENCODING = {{ data.encoding|qtLiteral }}{% endif %}{% if data.datcollate %}
File "/usr/share/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py", line 2079, in qtLiteral
adapted.encoding = 'utf8'
AttributeError: attribute 'encoding' of 'psycopg2.extensions.QuotedString' objects is not writable
推荐答案
在python代码中注释掉两行即可解决问题:
Commenting out two lines in python code resolves the issue:
sudo sed -i '2078,2079 s/^[^#]/#/'
/usr/share/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py
这些行是:
if hasattr(adapted, 'encoding'):
adapted.encoding = 'utf8'
这篇关于从 pgadmin4 创建数据库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!