Compare commits

...

8 commits

Author SHA1 Message Date
Dennis Priskorn 9f90fbd52d doc: README: Add more information about setup of database and role 2024-08-28 11:34:35 +02:00
Dennis Priskorn 2051da0220 Merge remote-tracking branch 'origin/add-documentation' into add-documentation 2024-08-28 11:34:32 +02:00
Dennis Priskorn c4dfa48fa3 doc: README: Add more information about download of geoip files 2024-08-28 11:19:29 +02:00
Dennis Priskorn 47104df2a7 doc: README: Add more information about venv setup 2024-08-28 11:19:29 +02:00
Dennis Priskorn 057296012c doc: README: Add more information about postgres setup 2024-08-28 11:19:29 +02:00
Dennis Priskorn b191940b6e WIP setup instructions 2024-08-28 11:19:29 +02:00
Dennis Priskorn 55d1efaf16 update gitignore 2024-08-28 11:19:29 +02:00
Edward Betts 0d2cfd56cb Add missing create_db.py script 2024-08-28 08:17:05 +00:00
2 changed files with 43 additions and 1 deletions

View file

@ -9,8 +9,15 @@
* start postgres * start postgres
* create postgres user * create postgres user
* `$ sudo su postgres` * `$ 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 * create the db tables
* TODO find out where credentials are stored
* setup credentials in default.py
* `$ python create_db.py`
* setup a venv * setup a venv
* enter the venv, e.g. in pycharm * enter the venv, e.g. in pycharm
* `$ pip install -r requirements.txt` * `$ pip install -r requirements.txt`

35
create_db.py Executable file
View file

@ -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()