Skip to content

abeerupadhyay/go-postgres-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Go application to demonstrate integration with postgresql

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published