| 1 |
# pgfortune |
| 2 |
|
| 3 |
pgfortune is a mock PostgreSQL server that responds to every query with a fortune. |
| 4 |
|
| 5 |
## Installation |
| 6 |
|
| 7 |
Install `fortune` and `cowsay`. They should be available in any Unix package manager (apt, yum, brew, etc.) |
| 8 |
|
| 9 |
``` |
| 10 |
go get -u github.com/jackc/pgproto3/example/pgfortune |
| 11 |
``` |
| 12 |
|
| 13 |
## Usage |
| 14 |
|
| 15 |
``` |
| 16 |
$ pgfortune |
| 17 |
``` |
| 18 |
|
| 19 |
By default pgfortune listens on 127.0.0.1:15432 and responds to queries with `fortune | cowsay -f elephant`. These are |
| 20 |
configurable with the `listen` and `response-command` arguments respectively. |
| 21 |
|
| 22 |
While `pgfortune` is running connect to it with `psql`. |
| 23 |
|
| 24 |
``` |
| 25 |
$ psql -h 127.0.0.1 -p 15432 |
| 26 |
Timing is on. |
| 27 |
Null display is "∅". |
| 28 |
Line style is unicode. |
| 29 |
psql (11.5, server 0.0.0) |
| 30 |
Type "help" for help. |
| 31 |
|
| 32 |
[email protected]:15432 jack=# select foo; |
| 33 |
fortune |
| 34 |
───────────────────────────────────────────── |
| 35 |
_________________________________________ ↵ |
| 36 |
/ Ships are safe in harbor, but they were \↵ |
| 37 |
\ never meant to stay there. /↵ |
| 38 |
----------------------------------------- ↵ |
| 39 |
\ /\ ___ /\ ↵ |
| 40 |
\ // \/ \/ \\ ↵ |
| 41 |
(( O O )) ↵ |
| 42 |
\\ / \ // ↵ |
| 43 |
\/ | | \/ ↵ |
| 44 |
| | | | ↵ |
| 45 |
| | | | ↵ |
| 46 |
| o | ↵ |
| 47 |
| | | | ↵ |
| 48 |
|m| |m| ↵ |
| 49 |
|
| 50 |
(1 row) |
| 51 |
|
| 52 |
Time: 28.161 ms |
| 53 |
``` |