PostgreSQL: Client Interface: Connection String

 17th December 2020 at 4:49pm

Connection string 是指在使用 C driver libpq 时,用来指定数据库的一串字符串。格式如下,遵循 RFC 3986:

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

例子:

postgresql://
postgresql://localhost
postgresql://localhost:5433
postgresql://localhost/mydb
postgresql://user@localhost
postgresql://user:secret@localhost
postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
postgresql://host1:123,host2:456/somedb?target_session_attrs=any&application_name=myapp

参考

PostgreSQL: Documentation: 13: 33.1. Database Connection Control Functions