Skip to content

Instantly share code, notes, and snippets.

@robconery
Created September 28, 2023 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robconery/7c76d783eb1790c4a17d7973159bc6e6 to your computer and use it in GitHub Desktop.
Save robconery/7c76d783eb1790c4a17d7973159bc6e6 to your computer and use it in GitHub Desktop.
SQL Extraction Inspect

Postgres ships with a powerful binary client, psql. If you're not a command line person, it can take a little getting used to. It's worth the investment, however, because the speed and scriptability of psql is extremely powerful.

You can login to your database with a simple command:

psql cassini

Once you're in, you can have a look around and see what's there:

\d
\d csvs.*

If you run a query on our master_plan table, you'll quickly find the results unreadable, which means we should use expanded display using \x - and sometimes that doesn't even help!

The easiest thing to do is to specify what you want to see, and to be sure you limit the results. This is our first select query!

select start_time_utc, duration, date from csvs.master_plan limit 5;

If you want to use a web-based GUI, you can run PG Web using Docker:

pgweb:
  container_name: pgweb
  restart: always
  image: sosedoff/pgweb
  ports:
    - "8080:8081"
  environment:
    - DATABASE_URL=postgres://rob@host.docker.internal/cassini?sslmode=disable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment