【发布时间】:2017-10-06 11:25:21
【问题描述】:
我有以下代码尝试测试与 postgres 的连接:
require 'pg'
conn = PGconn.connect("localhost", 5432, '', '', "puppetdb", "puppetdb", "puppetbdb")
res = conn.exec('select tablename, tableowner from pg_tables')
我得到了错误:
test.rb:3:in
initialize': FATAL: password authentication failed for user "puppetdb" (PG::ConnectionBad) from test.rb:3:innew' 来自 test.rb:3:in `'
但我有一个具有相同凭据的 python 脚本,似乎可以完美运行:
import psycopg2
try:
conn = psycopg2.connect("dbname='puppetdb' user='puppetdb' host='localhost' port='5432' password='puppetdb'")
鉴于 python 脚本,我想知道我是否输入了错误的凭据?
【问题讨论】:
-
localhost和172.17.0.1不一样 -
是的@C-Otto 我正在更新 python 脚本以读取本地主机。我刚刚在本地进行了测试,python 脚本适用于两个 URL。由于 Docker 网络正在共享到我的本地主机。
标签: ruby postgresql pg