PostgreSQL Connection URL

前端 未结 6 1991
离开以前
离开以前 2020-12-02 03:50

How is the PostgreSQL connection URL formed, when the host is some other computer than the localhost?

I have allowed PostgreSQL to accept requests from outside.

6条回答
  •  时光取名叫无心
    2020-12-02 04:28

    If you use Libpq binding for respective language, according to its documentation URI is formed as follows:

    postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
    

    Here are examples from same document

    postgresql://
    postgresql://localhost
    postgresql://localhost:5432
    postgresql://localhost/mydb
    postgresql://user@localhost
    postgresql://user:secret@localhost
    postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
    postgresql://localhost/mydb?user=other&password=secret
    

提交回复
热议问题