aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 7de1e8b7bd364daa4008c78efcf7081f21d38bb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
peeringdb-simplesync - Minimalistic PeeringDB synchronization tool
==================================================================

A simple tool for keeping a local PostgreSQL database up-to-date with PeeringDB.

Requirements
------------

* PostgreSQL 9.5+
* Python 3.6+
* psycopg2 2.7+
* python-requests 2+
* python-yaml


Installation
-----

```sh
sudo apt install git python3 python3-requests python3-psycopg2 python3-yaml

git clone https://git.2e8.dk/peeringdb-simplesync
cd peeringdb-simplesync

cp config.py.sample config.py
editor config.py # provide API-key

createdb pdbtest
psql pdbtest < schema.sql
```

Usage
-----

```sh
./sync.py # initial sync takes about 10 minutes
```

Then try the following query with `psql pdbtest`:

```sql
SELECT
	asn,
	data->>'irr_as_set',
	(data->>'info_prefixes4')::int pfx4,
	(data->>'info_prefixes6')::int pfx6
FROM peeringdb.net
WHERE deleted IS NULL
ORDER BY asn;
```

Note: if you add an `info_prefixes4` column to the schema,
then it will automatically be used, just like the `asn` column.

Disclaimer
----------

This tool is not affiliated with PeeringDB.