Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 1.13 KB

File metadata and controls

48 lines (32 loc) · 1.13 KB

Squirrel

An example of connecting to a postgres database using the sqlx and squirrel packages

Requirements

  • Docker
  • Docker Compose

We will be using Docker to spin up a Postgres instance.

Setup

  1. Launch a new shell session and start Postgres:

    $ docker-compose up
  2. You can connect to Postgres from the shell:

    $ docker exec -it postgres psql postgres://pguser:password@localhost/db
    psql (12.11)
    Type "help" for help.
    
    db=# SELECT * FROM users;
     id  |         created_at         |         updated_at         |      email      | username | first_name | last_name
    -----+----------------------------+----------------------------+-----------------+----------+------------+-----------
     123 | 2023-07-25 00:04:13.652829 | 2023-07-25 00:04:13.652829 | jon@example.com | jonny    | Jon        | Murphy
  3. Run the program

    $ go run .
  4. When all is done, teardown Postgres.

    $ docker-compose down

Reference and Credits