Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the format for the PostgreSQL connection string / URL?

What is the format for the PostgreSQL connection string (URL postgres://...) when the host is not the localhost?

like image 822
JII Avatar asked Aug 27 '10 08:08

JII


People also ask

What is the connection string for PostgreSQL?

Driver={PostgreSQL ANSI};Server=IP address;Port=5432;Database=myDataBase;Uid=myUsername;Pwd=myPassword;sslmode=require; Please note that sslmode=require is case sensitive, it should be written in lower case letters.

Does postgres use TCP or HTTP?

PostgreSQL uses a message-based protocol for communication between frontends and backends (clients and servers). The protocol is supported over TCP/IP and also over Unix-domain sockets.


1 Answers

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 
like image 127
Andrey Avatar answered Sep 18 '22 11:09

Andrey