尝试使用sqlalchemy连接到postgres数据库时遇到此身份验证问题。 这就是我的联系方式:
public class Main {
public static void main(String[] args) {
SessionFactory sessionFactory = new SessionFactory("com.my.package.name");
Session session = sessionFactory.openSession();
Root r = new Root()
r.addLeaf(new Leaf(), 1);
r.addLeaf(new Leaf(), 2);
session.save(r);
//Until this point everything is alright and
// all 3 nodes and 2 relationships are created
String query = "MATCH path = (l1:Leaf)-[*1..100]-(l2:Leaf) WITH path LIMIT 1 RETURN path";
QueryResultModel qrm = session.query(query, new HashMap<String, Object>());
// qrm.result.get(0).get("path") is null
}
}
这就是我设置db_url = 'postgresql+psycopg2:///<role>:<pass>@localhost:5432/basketball'
Engine = create_engine(db_url, echo=False)
SessionMaker = ORM.sessionmaker(bind=Engine, autoflush=False)
Session = ORM.scoped_session(SessionMaker)
/etc/postgresql/9.3/main/pg_hba.conf
然后,当访问db时,我得到:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5