Skip to content

Commit a6947a1

Browse files
committed
Add README
1 parent 25bfcff commit a6947a1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
wait-for-db
2+
===========
3+
[![Build Status](https://travis-ci.com/palfrey/wait-for-db.svg?branch=master)](https://travis-ci.com/palfrey/wait-for-db)
4+
5+
Basically, [wait-for-it](https://github.com/vishnubob/wait-for-it) but for databases.
6+
7+
Often ([especially within Dockerised configurations](https://docs.docker.com/compose/startup-order/)) there is the problem of "I need the database to be up before step X will work". Now, if all you need is "up" then generally wait-for-it and the database port is enough. If on the other hand you've got migration scripts or other such things you need to run on your database, up isn't enough.
8+
9+
wait-for-db lets you wait for a particular database to be both up (in the sense of "will let you connect without errors") and optionally "returns at least one row to a particular query". It will also attempt to fail immediately for permanent failures (e.g. syntax errors)
10+
11+
Usage
12+
-----
13+
1. Download static binary from https://github.com/palfrey/wait-for-db/releases into your Docker image
14+
2. `./wait-for-db <options>`
15+
16+
Options
17+
-------
18+
* `-m/--mode`: `postgres` or `odbc`
19+
* `-c/--connection-string`: Mode-appropriate connection string. So `postgresql://<username>:<pasword>@<host>:<port>` or `Driver=<path to driver>;<various ODBC options>` depending on your driver
20+
* `-s/--sql-text`: SQL query to run once connected. It should return at least one row, or will be regarded as failing. Default: no query, just be regarded as succeeding the moment it connects.
21+
* `-p/--pause`: Pause between attempts for non-permanent failures. Default is 3 seconds
22+
* `-t/--timeout`: Time to wait before failing entirely. Default is wait forever.
23+
24+
Database support
25+
----------------
26+
* Anything you've got an [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity) driver for (which should be most SQL databases)
27+
* Postgres

0 commit comments

Comments
 (0)