From 0d2cfd56cb3761e2025a75313216ee78eeee1e98 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 28 Aug 2024 08:17:05 +0000 Subject: [PATCH 1/7] Add missing create_db.py script --- create_db.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 create_db.py diff --git a/create_db.py b/create_db.py new file mode 100755 index 0000000..2c1c6f9 --- /dev/null +++ b/create_db.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 + +from sqlalchemy.schema import CreateIndex, CreateTable + +from matcher import database, model + +DB_URL = "postgresql:///matcher" +database.init_db(DB_URL) + + +def create_db(): + model.Base.metadata.create_all(database.session.get_bind()) + + +def print_create_table(classes): + database.init_db(DB_URL) + + engine = database.session.get_bind() + + for cls in classes: + sql = str(CreateTable(cls.__table__).compile(engine)) + print(sql.strip() + ";") + + for index in cls.__table__.indexes: + sql = str(CreateIndex(index).compile(engine)) + print(sql.strip() + ";") + + +# print_create_table([model.ItemIsA]) +# print_create_table([model.EditSession]) +# print_create_table([model.Changeset, model.ChangesetEdit, model.SkipIsA]) +# print_create_table([model.User]) +# print_create_table([model.Extract]) + +create_db() From 55d1efaf16989c3304a23f5fb90caa2e015f9149 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Sat, 4 May 2024 22:03:23 +0200 Subject: [PATCH 2/7] update gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 03f1c6e..a5e1081 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,8 @@ venv __pycache__ .mypy_cache/ config/default.py +node_modules/ +.vscode/ +config.default +package-lock.json +config/ From b191940b6e9c3ccaf9714e8707aa2419963aff60 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Sat, 4 May 2024 22:03:47 +0200 Subject: [PATCH 3/7] WIP setup instructions --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e54b665 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# OWL-MAP + +## Setup +* clone the project +* install geoip and postgres from your local package manager +* setup av venv +* enter the venv +* run 'pip install -r requirements.txt' +* cp config/examply.py config/default.py +* setup /var/lib/data/GeoLite2/GeoLite2-City.mmdb somehow +* run 'python web_view.py' From 057296012cf6326d06359cf59d4828cb1de50e52 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Wed, 28 Aug 2024 09:42:35 +0200 Subject: [PATCH 4/7] doc: README: Add more information about postgres setup --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e54b665..5759774 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,14 @@ ## Setup * clone the project * install geoip and postgres from your local package manager -* setup av venv +* setup postgres on your machine, see e.g. https://wiki.archlinux.org/title/PostgreSQL + * `$ sudo su postgres` + * `$ initdb -D /var/lib/postgres/data` +* start postgres +* create postgres user + * `$ sudo su postgres` + * `$ createuser --interactive` -> owl +* setup a venv * enter the venv * run 'pip install -r requirements.txt' * cp config/examply.py config/default.py From 47104df2a79526e0e99a48410880d1bf224ec18e Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Wed, 28 Aug 2024 09:50:15 +0200 Subject: [PATCH 5/7] doc: README: Add more information about venv setup --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5759774..d105c90 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ * `$ sudo su postgres` * `$ createuser --interactive` -> owl * setup a venv -* enter the venv -* run 'pip install -r requirements.txt' + * enter the venv, e.g. in pycharm + * `$ pip install -r requirements.txt` * cp config/examply.py config/default.py * setup /var/lib/data/GeoLite2/GeoLite2-City.mmdb somehow * run 'python web_view.py' From c4dfa48fa3df0a7e0dea593d38c4de5d469999a5 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Wed, 28 Aug 2024 10:44:39 +0200 Subject: [PATCH 6/7] doc: README: Add more information about download of geoip files --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d105c90..113c22a 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,17 @@ * create postgres user * `$ sudo su postgres` * `$ createuser --interactive` -> owl +* create the db tables * setup a venv * enter the venv, e.g. in pycharm * `$ pip install -r requirements.txt` -* cp config/examply.py config/default.py -* setup /var/lib/data/GeoLite2/GeoLite2-City.mmdb somehow +* `$ cp config/example.py config/default.py` +* download id-tagging-schema + * `$ git clone https://github.com/openstreetmap/id-tagging-schema` + * adjust paths in default.py +* download geoip databases + * https://git.io/GeoLite2-City.mmdb + * `$ pacman -S geoip-database-extra` in ArchLinux or https://dl.miyuru.lk/geoip/maxmind/city/maxmind4.dat.gz + * adjust default.py +* run the tests * run 'python web_view.py' From 9f90fbd52de6857d9d634c9d63674f7aaec6e07c Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Wed, 28 Aug 2024 11:34:35 +0200 Subject: [PATCH 7/7] doc: README: Add more information about setup of database and role --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 113c22a..f091533 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,15 @@ * start postgres * create postgres user * `$ sudo su postgres` - * `$ createuser --interactive` -> owl + * `$ createuser --interactive` -> "owl" role with relevant priviledges +* create postgres database "matcher" + * `$ psql -U postgres` + * `> CREATE DATABASE matcher;` + * `> ALTER DATABASE matcher OWNER TO owl;` * create the db tables + * TODO find out where credentials are stored + * setup credentials in default.py + * `$ python create_db.py` * setup a venv * enter the venv, e.g. in pycharm * `$ pip install -r requirements.txt`