将Apache Superset与PostgreSQL连接

时间:2019-12-09 11:16:51

标签: postgresql superset apache-superset

假设我在Docker之上运行Apache Superset,并且希望它与我的本地postgreSQL服务器连接。我使用以下URI,但出现错误:

postgresql+psycopg2://username:password@localhost:5432/mydb

错误是:

ERROR: {"error": "Connection failed!\n\nThe error message returned was:\n(psycopg2.OperationalError) could not connect to server: Connection refused\n\tIs the server running on host \"localhost\" (127.0.0.1) and accepting\n\tTCP/IP connections on port 5432?\ncould not connect to server: Cannot assign requested address\n\tIs the server running on host \"localhost\" (::1) and accepting\n\tTCP/IP connections on port 5432?\n\n(Background on this error at: http://sqlalche.me/e/e3q8)", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py\", line 2265, in _wrap_pool_connect\n    return fn()\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py\", line 303, in unique_connection\n    return _ConnectionFairy._checkout(self)\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py\", line 760, in _checkout\n    fairy = _ConnectionRecord.checkout(pool)\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py\", line 492, in checkout\n    rec = pool._do_get()\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py\", line 238, in _do_get\n    return self._create_connection()\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py\", line 308, in _create_connection\n    return _ConnectionRecord(self)\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py\", line 437, in __init__\n    self.__connect(first_connect_check=True)\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py\", line 639, in __connect\n    connection = pool._invoke_creator(self)\n  File \"/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py\", line 114, in ...

我该如何解决?

2 个答案:

答案 0 :(得分:2)

我也遇到了这个问题!与我以前连接时相同的错误和连接字符串。 代替使用localhost或127.0.0.1,打开您的 pgAdmin 。 服务器位于左侧

  • 单击下拉列表。
  • 右键单击现在打开的群集(“数据库”上方的级别)并打开属性。
  • 导航至打开的连接选项卡,主机名/地址将替代“ localhost”

还要确保连接字符串的最后部分指向您的数据库,该数据库位于pgAdmin中“数据库”的下一级。

我希望这是有用的,我自己做了!

答案 1 :(得分:0)

我知道将Docker与主机数据库连接是一种不道德的行为,因此我改变了看法,并在Docker内部使用postgres映像并将数据推送到该postgres服务器。 如果我错了,通知您会很有帮助。