package main import ( "database/sql" "fmt" _ "github.com/jackc/pgx/v4/stdlib" // stdlib is the package that provides the standard library driver. To be able to use database sql package ) type PostgresConfig struct { Host string Port string User string Password string Database string SSLMode string } func (cfg PostgresConfig) String() string { return fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s", cfg.Host, cfg.Port, cfg.User, cfg.Password, cfg.Database, cfg.SSLMode) } func main() { cfg := PostgresConfig{ Host: "localhost", Port: "5432", User: "baloo", Password: "junglebook", Database: "lenslocked", SSLMode: "disable", } // pgx = Driver name defined by github.
Today it was a bit of lazy day so here it is…
docker compose start [+] Running 2/2 ⠿ Container section-9-adminer-1 Started 0.4s ⠿ Container section-9-db-1 Started docker compose exec -it db psql -U baloo -d lenslocked psql (15.2 (Debian 15.2-1.pgdg110+1)) Type "help" for help. lenslocked=# lenslocked=# Deleting (dropping) a table lenslocked=# DROP TABLE IF EXISTS users; DROP TABLE lenslocked=# Adding comments lenslocked'# lenslocked'# -- Creating the "users" table lenslocked'# Creating a table lenslocked=# CREATE TABLE users ( lenslocked(# id SERIAL PRIMARY KEY, lenslocked(# age INT, lenslocked(# first_name TEXT, lenslocked(# last_name TEXT, lenslocked(# email TEXT UNIQUE NOT NULL lenslocked(# ); CREATE TABLE lenslocked=# lenslocked=# SELECT * FROM users; id | age | first_name | last_name | email ----+-----+------------+-----------+------- (0 rows) lenslocked=# lenslocked=# INSERT INTO users VALUES (1, 22, 'Alex', 'Rabocse', 'alex@email.
First, I am running postgres in a container.
More specifically, I am using docker compose, so here is the yaml file:
version: "3.9" services: # Our Postgres database db: # The service will be named db. image: postgres # The postgres image will be used restart: always # Always try to restart if this stops running environment: # Provide environment variables POSTGRES_USER: baloo # POSTGRES_USER env var w/ value baloo POSTGRES_PASSWORD: junglebook POSTGRES_DB: lenslocked # Database name ports: # Expose ports so that apps not running via docker-compose can connect to them.
Contents Contents WARNING: Why Was I Doing All this? Salesforce Backlog CLI Requirements TLDR (Execution with Docker) Current State Script’s Data Flow Caveats Progress and Roadmap What Did I Learn? What Is Next? WARNING: Dear non existing reader, I am not going to bullshit you. If, for any strange reason, you checked my Github repo or my DockerHub some time ago, you will realize that I am copying and pasting most of that content here.