summaryrefslogtreecommitdiff
path: root/temp-postgres.1
diff options
context:
space:
mode:
Diffstat (limited to 'temp-postgres.1')
-rw-r--r--temp-postgres.147
1 files changed, 41 insertions, 6 deletions
diff --git a/temp-postgres.1 b/temp-postgres.1
index 1adb8ed..324a2f1 100644
--- a/temp-postgres.1
+++ b/temp-postgres.1
@@ -20,6 +20,8 @@
.Sh SYNOPSIS
.Nm temp-postgres
.Op options
+.Op Fl -
+.Op Ar command
.Sh DESCRIPTION
The
.Nm
@@ -30,23 +32,56 @@ The options are as follows:
.It Fl h , -help
Print help.
.It Fl d , -dbname Ar dbname
-The PostgreSQL database name.
+Database name.
Defaults to the name of the effective user.
.It Fl u , -username Ar username
-The PostgreSQL user name.
+PostgreSQL user name.
Defaults to the name of the effective user.
.El
+.Pp
+.Nm
+can optionally execute a given
+.Ar command
+once the PostgreSQL server is ready.
+If so,
+.Nm
+will pass the following environment variables to the
+.Ar command :
+.Bl -tag -width Ds
+.It Ev PGHOST
+Absolute path to the directory in which the UNIX domain socket file is stored.
+.It Ev PGDATABASE
+Database name.
+.It Ev PGUSER
+PostgreSQL user name.
+.It Ev DATABASE_URI
+Connection URI.
+.It Ev DATABASE_URL
+Connection URI.
+.El
+.Pp
+See also the
+.Lk https://www.postgresql.org/docs/current/libpq-envars.html "environment variables used by libpg" ,
+and the
+.Lk https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS "connection URI scheme understood by libpg" .
.Sh EXIT STATUS
.Ex -std temp-postgres
.Sh EXAMPLES
-Create a temporary database "test" with superuser "alex":
+Create and serve a temporary database:
.Bd -literal -offset indent
-$ temp-postgres --dbname test --username alex
+$ temp-postgres
.Ed
.Pp
-Connect to the "test" database:
+Specify a database name, and PostgreSQL user name:
+.Bd -literal -offset indent
+$ temp-postgres --dbname myproject --username alex
+.Ed
+.Pp
+Wrap the
+.Xr psql 1
+command to connect to the temporary database once the server is ready:
.Bd -literal -offset indent
-$ psql --host=localhost test alex
+$ temp-postgres -- psql
.Ed
.Sh SEE ALSO
.Xr postgres 1 ,
Generated by cgit. See skreutz.com for my tech blog and contact information.