• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    C
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

' tail -f ' your PostgreSQL tables.

pg_tail

Watch last lines of a PostgreSQL table like in a "tail -f".
( inspired by mysqltail )

Install

macOS

brew install aaparmeggiani/tap/pg_tail

*nix

(requires PostgreSQL, pg_config, libpq)

git clone https://github.com/aaparmeggiani/pg_tail.git
cd pg_tail
make
make install

Usage

% pg_tail [OPTIONS] -t TABLE -c uKEY[,COL1,..,COLn]

Options:
    -d, --dbname=DBNAME         database to connect to
    -h, --host=HOSTNAME         database server host or socket directory
    -p, --port=PORT             database server port number
    -U, --username=NAME         connect as specified database user
    -W, --password              prompts for the user password


    -t, --table=TABLE           table to watch
    -c, --columns=COL1..COLn    columns to watch, the first one must be an ordered primary key (sequence)
    -i, --interval=SECONDS      database polling interval in seconds (default: 10)
    -s, --separator=CHAR        sets a column delimiter (an no column alignment)
    -n  NUM                     number of lines in the first polling (default: 5)
    -j, --json                  output as json    
    -v, --version               version info

Options can also be passed through the following PG / PGTAIL env variables:

PGDATABASE, PGHOST, PGPORT, PGUSER

PGTAILTABLE, PGTAILKEY, PGTAILCOLUMNS, PGTAILSEPARATOR, PGTAILINTERVAL, PGTAILLINES, PGTAILALIGN, PGTAILJSON

Example

% pg_tail -d database -t users -c id,login,email
id | login  | email              |
1  | system | [email protected] |
2  | global | [email protected] |
3  | teller | [email protected] |

Dockerized

Docker Automated Status Docker Build Status

docker run -it --init --rm aaparmeggiani/pg_tail --help

(don't forget --init or you might find yourself trapped without ctrl-c =)

License

MIT