---json
{
"aliases": [
{ "path": ":docs:howto:connection" },
{ "path": ":docs:system:postgres:howto" },
{ "path": ":howto:postgres:connection" }
],
"page_id": "qz5o6cyeba81k6l2in3pr"
}
---
====== Postgres - How-to Connection ======
===== About =====
A [[docs:connection:howtos|default howto postgres connection]] and [[docs:service:howtos|howto service]] are provided after a fresh installation that is used in the [[howto:howto|howto's]].
To use this connection, you need to start the service (ie a [[#docker|docker image]])
===== Docker =====
==== Download and run the image ====
This connection is based on the [[https://hub.docker.com/_/postgres|Official Postgres Docker image]].
* You can download and start the image with the following command:
With [[:docs:tabul:service:start_command|tabul service start]]
tabul service start postgres
* [[docs:common:bash|Bash]]
docker run \
-e POSTGRES_PASSWORD=welcome \
-p 5432:5432 \
-d \
--name postgres \
postgres:13.21
* [[docs:common:shell|CMD/Powershell]]
docker run ^
-e POSTGRES_PASSWORD=welcome ^
-p 5432:5432 ^
-d ^
--name postgres ^
postgres:13.21
\\
* [[docs:tabul:connection:ping|Ping]] your connection to check that the database is up.
tabul connection ping postgres
The connection (postgres) has been pinged successfully
==== Start / Stop ====
You can then start and stop the image with the following command:
docker stop postgres
docker start postgres
===== Info =====
tabul connection info postgres
Information about the connection (postgres)
Attribute Value Description
-------------------------- ----------------------------------------- --------------------------------------------------------------------
BOOLEAN_DATA_TYPE Native Boolean data type used to store boolean values
BUILDER_CACHE_ENABLED true Enable or disable the builder cache
CHAR_DEFAULT_PRECISION 1 Default CHAR precision
COMMENT The howto postgres connection A connection description
DATABASE_MAJOR_VERSION The major version number of the database
DATABASE_MINOR_VERSION The minor version number of the database
DATABASE_PRODUCT_NAME The name of the database
DATABASE_PRODUCT_VERSION The version of the database
DATE_DATA_TYPE NATIVE Date data type used to store date values
DRIVER org.postgresql.Driver The jdbc driver class
DRIVER_NAME The driver name
DRIVER_VERSION The driver version
HOST Host Server
JDBC_MAJOR_VERSION The major version number of JDBC
JDBC_MINOR_VERSION The minor version number of JDBC
LOGIN_STATEMENTS Statements that runs after a connection has been established
MAX_CONCURRENT_THREAD The maximum number of threads that can be created against the system
MAX_NAME_IN_PATH The maximum number of names in a path
NAME postgres The name of the connection
NAME_QUOTING_DISABLED_CASE UPPERCASE The case to apply when quoting is disabled
NAME_QUOTING_ENABLED true Enable quoting of names
NATIVES Native Driver attributes (jdbc properties, ...)
NCHAR_DEFAULT_PRECISION 1 Default NCHAR precision
NVARCHAR_DEFAULT_PRECISION 0 Default NVARCHAR precision
ORIGIN CONF The origin of the connection
PASSWORD welcome The user password
PORT 5432 Host Port
SUPPORT_BATCH_UPDATES If the system supports batch SQL updates
SUPPORT_NAMED_PARAMETERS If the system supports named parameters in the SQL statement
TIMESTAMP_DATA_TYPE NATIVE Timestamp data type used to store timestamp values
TIME_DATA_TYPE NATIVE Time format data type to store time values
URI jdbc:postgresql://localhost:5432/postgres The uri of the connection
USER postgres The user name
VARCHAR_DEFAULT_PRECISION 0 Default VARCHAR precision
WORKING_PATH public. The working path (Schema for database, directory for file system)
===== Support =====
==== Docker WSL2: Connection to localhost:5432 refused ====
If you get this message using Docker WSL2 on windows:
```
Connection to localhost:5432 refused
Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
```
You can try get the IP of the wsl machine
```bash
ip -br a
```
and use it in place of localhost. Example:
```bash
tabul connection upsert --uri "jdbc:postgresql://172.31.112.26:5432/postgres" postgres
```
Other user have reported that the following steps may help:
* Settings another docker network space in `Docker > Settings > Docker Engine configuration`:
```json
{
"bip": "192.168.200.1/24",
}
```
* restart your computer