Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 1daded2

Browse files
committed
README: Added explanation + example for config file
1 parent 6a0ba8b commit 1daded2

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,57 @@ Options:
201201
- `--bisection-factor` - Segments per iteration. When set to 2, it performs binary search.
202202
- `--bisection-threshold` - Minimal bisection threshold. i.e. maximum size of pages to diff locally.
203203
- `-j` or `--threads` - Number of worker threads to use per database. Default=1.
204+
- `--conf`, `--run` - Specify the run and configuration from a TOML file. (see below)
205+
206+
### How to use with a configuration file
207+
208+
Data-diff lets you load the configuration for a run from a TOML file.
209+
210+
Reasons to use a configuration file:
211+
212+
- Convenience - Set-up the parameters for diffs that need to run often
213+
214+
- Easier and more readible - You can define the database connection settings as config values, instead of in a URI.
215+
216+
- Gives you fine-grained control over the settings switches, without requiring any Python code.
217+
218+
Use `--conf` to specify that path to the configuration file. data-diff will load the settings from `run.default`, if it's defined.
219+
220+
Then you can, optionally, use `--run` to choose to load the settings of a specific run, and override the settings `run.default`. (all runs extend `run.default`, like inheritance).
221+
222+
Finally, CLI switches have the final say, and will override the settings defined by the configuration file, and the current run.
223+
224+
Example TOML file:
225+
226+
```toml
227+
# Specify the connection params to the test database.
228+
[database.test_postgresql]
229+
driver = "postgresql"
230+
user = "postgres"
231+
password = "Password1"
232+
233+
# Specify the default run params
234+
[run.default]
235+
update_column = "timestamp"
236+
verbose = true
237+
238+
# Specify params for a run 'test_diff'.
239+
[run.test_diff]
240+
verbose = false
241+
# Source 1 ("left")
242+
1.database = "test_postgresql" # Use options from database.test_postgresql
243+
1.table = "rating"
244+
# Source 2 ("right")
245+
2.database = "postgresql://postgres:Password1@/" # Use URI like in the CLI
246+
2.table = "rating_del1"
247+
```
248+
249+
In this example, running `data-diff --conf myconfig.toml --run test_diff` will compare between `rating` and `rating_del1`.
250+
It will use the `timestamp` column as the update column, as specified in `run.default`. However, it won't be verbose, since that
251+
flag is overwritten to `false`.
252+
253+
Running it with `data-diff --conf myconfig.toml --run test_diff -v` will set verbose back to `true`.
254+
204255

205256
## How to use from Python
206257

0 commit comments

Comments
 (0)