Wait until database connection can be successfully established
Go to file
CSRBot 4e9b4385f8
Some checks failed
renovate/artifacts Artifact file update failure
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
chore(deps): update module github.com/sijms/go-ora/v2 to v2.8.16
2024-05-06 14:14:34 +02:00
cmd fix: update go sums 2022-08-08 18:50:51 +02:00
pkg/dbwait fix(oracle): select 1 from dual 2022-09-13 17:31:24 +02:00
.dockerignore Initial Commit 2021-09-15 22:18:06 +02:00
.drone.yml chore(deps): update quay.io/skopeo/stable docker tag to v1.15.0 2024-03-31 16:05:20 +00:00
.editorconfig Initial Commit 2021-09-15 22:18:06 +02:00
.gitattributes Initial Commit 2021-09-15 22:18:06 +02:00
.gitignore Initial Commit 2021-09-15 22:18:06 +02:00
.golangci.yml Initial Commit 2021-09-15 22:18:06 +02:00
.markdownlint.yaml Initial Commit 2021-09-15 22:18:06 +02:00
Dockerfile chore(deps): update docker.io/library/golang docker tag to v1.22.2 2024-04-03 19:42:37 +00:00
go.mod chore(deps): update module github.com/sijms/go-ora/v2 to v2.8.16 2024-05-06 14:14:34 +02:00
go.sum chore(deps): update module github.com/sijms/go-ora/v2 to v2.8.15 2024-05-03 01:02:24 +00:00
LICENSE Initial Commit 2021-09-15 22:18:06 +02:00
main.go fix: update go sums 2022-08-08 18:50:51 +02:00
Makefile Initial Commit 2021-09-15 22:18:06 +02:00
manifest.tmpl fix(ci): unsupport arm v7 2023-10-30 21:39:08 +01:00
README.md Initial Commit 2021-09-15 22:18:06 +02:00
renovate.json fix(renovate): remove automerge options 2024-01-21 15:02:17 +01:00

db-wait

Build Status Docker Pulls

With db-wait is it possible to wait in CI/CD environments until a database connection can be established and SQL queries are possible.

This is very useful for example when a database is started for an integration test and it needs time to start and initialize all schemes before the test connects to it.

Usage

As argument db-wait expects a database URI. This can be different depending on the backend. Currently only oracle and postgres are supported. The supported URI patterns can be found in the respective library or directly in the documentation of the database backend.

For example:

# postgres
db-wait postgres://user:password@localhost:5432/postgres?sslmode=disable

# oracle
db-wait oracle://user:password@localhost:1521/xe

More about URI Pattern is documented here for oracle and postgres.

Installation

There are two ways to install db-wait. Directly via go or via make in combination with git and go. The advantage of the second option is that the binary is installed with all the additional files that the developer specifies.

# go
$ go install git.cryptic.systems/volker.raschek/db-wait

# git, make, go
$ git clone https://git.cryptic.systems/volker.raschek/db-wait.git && \
  cd db-wait && \
  make install PREFIX=/usr

Usage as container image

Alternatively can be db-wait used as container image. A local installation is not necessary.

# postgres
$ docker run --rm --network host docker.io/volkerraschek/db-wait:latest \
    postgres://user:password@localhost:5432/postgres?sslmode=disable

# oracle
$ docker run --rm --network host docker.io/volkerraschek/db-wait:latest \
    oracle://user:password@localhost:1521/xe