You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module was designed to do partial dump (filtered dump) on a set of tables taking in account
4
+
all their foreign_keys, so table they are referencing.
5
+
If you have a huge database and you want to extract a small set of data (with there dependencies in other tables) to work on it and them re-import the datas
6
+
this script is made for you.
7
+
8
+
Filtering is made using SQL where statement on a SELECT statement with all tables relations handeled as INNER or LEFT JOIN (depending on the nullability of the foreign_key).
9
+
10
+
The generated dump is a set of COPY statements with raw values, so that it can handle all type of values (dates, binary, postgis points ...).
11
+
12
+
## Installation
4
13
```bash
5
14
pip install -r requirements.txt
15
+
python setup.py install
16
+
```
17
+
18
+
## How to use it
19
+
20
+
### Command line interface
21
+
22
+
```bash
23
+
Usage:
24
+
pg-dump-filtered [options] <db-uri><table-list>
25
+
26
+
Arguments:
27
+
db-uri URI of the postgres database, for instance : postgresql://pg_dump_test:pg_dump_test@localhost:5432/pg_dump_test
28
+
table-list List of the table that needs to be exported, separated by commas (related tables will automatically be exported).
29
+
Eg :'table1,table2,table3'
30
+
31
+
Options:
32
+
-h --help Show this screen.
33
+
--filters=<SQL> SQL filters. Eg: mytable.mycol = 'value' AND myothertable.toto LIKE 'titi'
34
+
--ignored-constraints=<str> List of constraints to be ignored. Eg :"myconstraint,myotherconstraint"
pg-dump-filtered "postgres://user:pwd@host/db""tableA,tableB" --debug --filters="mytable.id=85 AND ....." --ignored-constraints="a_circular_constraint_name"
40
+
```
41
+
42
+
### Python Interface
43
+
44
+
For [Open Path View](https://openpathview.fr) whe needed to export small set a data depending on their geolocalisation and list some row of the exported datas (files UUID as files where saved in the database).
0 commit comments