From 91e3f78e5d8d643d551b79f418cf8a971c8051df Mon Sep 17 00:00:00 2001 From: Igor Shubovych Date: Thu, 8 May 2014 17:10:08 +0300 Subject: [PATCH 1/4] Pages: psql --- pages/common/psql.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pages/common/psql.md diff --git a/pages/common/psql.md b/pages/common/psql.md new file mode 100644 index 000000000..85b24c9af --- /dev/null +++ b/pages/common/psql.md @@ -0,0 +1,19 @@ +# psql + +> PostgreSQL command-line client + +- Connect to database. It connects to localhost using default port *5432* with default user. + +`psql {{database}}` + +- Connect to database on given server host running on given port with username given + +`psql -h {{host}} -p {{port}} -U {{username}} mydb` + +- Run query against the given database + +`echo '{{query}}' | psql {{database}}` + +or + +`psql -c '{{query}}' {{database}}` From 82564bd2220bc0d3fe4703eb137c025bde33fb47 Mon Sep 17 00:00:00 2001 From: Igor Shubovych Date: Mon, 12 May 2014 14:44:31 +0300 Subject: [PATCH 2/4] psql: split examples, minor fixes --- pages/common/psql.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pages/common/psql.md b/pages/common/psql.md index 85b24c9af..45ed18ac6 100644 --- a/pages/common/psql.md +++ b/pages/common/psql.md @@ -2,18 +2,18 @@ > PostgreSQL command-line client -- Connect to database. It connects to localhost using default port *5432* with default user. +- Connect to *database*. It connects to localhost using default port *5432* with default user `psql {{database}}` -- Connect to database on given server host running on given port with username given +- Connect to *database* on given server *host* running on given *port* with *username* given -`psql -h {{host}} -p {{port}} -U {{username}} mydb` +`psql -h {{host}} -p {{port}} -U {{username}} {{database}}` -- Run query against the given database - -`echo '{{query}}' | psql {{database}}` - -or +- Run single *query* against the given *database*. Note: useful in shell scripts `psql -c '{{query}}' {{database}}` + +- Run semicolon-separated *queries* against the given *database*. Note: useful in shell scripts + +`echo '{{queries}}' | psql {{database}}` \ No newline at end of file From b74dff1d798ef60b3a727fe45871ee6a007129a5 Mon Sep 17 00:00:00 2001 From: Igor Shubovych Date: Mon, 12 May 2014 23:54:47 +0300 Subject: [PATCH 3/4] psql: use here-strings instead of echo --- pages/common/psql.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/common/psql.md b/pages/common/psql.md index 45ed18ac6..1f9d30ea2 100644 --- a/pages/common/psql.md +++ b/pages/common/psql.md @@ -14,6 +14,6 @@ `psql -c '{{query}}' {{database}}` -- Run semicolon-separated *queries* against the given *database*. Note: useful in shell scripts +- Run several queries against the given *database*. Note: useful in shell scripts -`echo '{{queries}}' | psql {{database}}` \ No newline at end of file +`psql {{database}} <<< "{{query1}}; {{query2}}"` \ No newline at end of file From 41974a77fd441954c43d3d3c15ae72983712edb7 Mon Sep 17 00:00:00 2001 From: Igor Shubovych Date: Sat, 17 May 2014 15:48:09 +0300 Subject: [PATCH 4/4] psql: minor syntax changes --- pages/common/psql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/psql.md b/pages/common/psql.md index 1f9d30ea2..df25c816c 100644 --- a/pages/common/psql.md +++ b/pages/common/psql.md @@ -16,4 +16,4 @@ - Run several queries against the given *database*. Note: useful in shell scripts -`psql {{database}} <<< "{{query1}}; {{query2}}"` \ No newline at end of file +`echo '{{query1}}; {{query2}}' | psql {{database}}` \ No newline at end of file