forked from edward/owl-map
Compare commits
No commits in common. "9f90fbd52de6857d9d634c9d63674f7aaec6e07c" and "92456553e6341ec625a4cd1a179d83fb3146a264" have entirely different histories.
9f90fbd52d
...
92456553e6
|
@ -9,15 +9,8 @@
|
|||
* start postgres
|
||||
* create postgres user
|
||||
* `$ sudo su postgres`
|
||||
* `$ createuser --interactive` -> "owl" role with relevant priviledges
|
||||
* create postgres database "matcher"
|
||||
* `$ psql -U postgres`
|
||||
* `> CREATE DATABASE matcher;`
|
||||
* `> ALTER DATABASE matcher OWNER TO owl;`
|
||||
* `$ createuser --interactive` -> 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`
|
||||
|
|
35
create_db.py
35
create_db.py
|
@ -1,35 +0,0 @@
|
|||
#!/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()
|
Loading…
Reference in a new issue