go-postgres-example

command module
v0.0.0-...-2307dbf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 5 Imported by: 0

README

go-postgres-example Build Status DeepSource

Go application to demonstrate integration with postgresql

To run the script locally, set PG_DEFAULT_CONN_URI=postgres://myuser:pass123@localhost:5432/mydb?sslmode=disable and PG_MIGRATIONS_FILE_PATH=/path/to/project/database/migrations in your environment variables and run go run main.go. If the values were set correctly, you must see the following output

INFO[0000] Migrations applied successfully               ctx=postgres
INFO[0000] Connection established to database.           ctx=postgres database=localdb host="localhost:5432"
INFO[0000] Book created                                  book_id=1 ctx=postgres
INFO[0000] Book created                                  book_id=2 ctx=postgres
INFO[0000] Book deleted                                  book_id=1 ctx=postgres
INFO[0000] Book deleted                                  book_id=2 ctx=postgres
INFO[0000] Default connection closed!                    ctx=postgres

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL