From b2c07ee41d7d312739fa5b71ed0652011782eadc Mon Sep 17 00:00:00 2001 From: jgenero Date: Sun, 16 Oct 2022 12:19:39 +0200 Subject: [PATCH] renamed : princes_db_tables.py -> data.py --- app/modeles/data.py | 126 +++++++++++++++++++++++++++++++ app/modeles/princes_db_tables.py | 114 ---------------------------- 2 files changed, 126 insertions(+), 114 deletions(-) create mode 100644 app/modeles/data.py delete mode 100644 app/modeles/princes_db_tables.py diff --git a/app/modeles/data.py b/app/modeles/data.py new file mode 100644 index 0000000..1cdb365 --- /dev/null +++ b/app/modeles/data.py @@ -0,0 +1,126 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +""" +Authors : Jean-Damien Généro +Affiliation : French National Center for Scientific Research (CNRS) +Assigned at the Centre de recherches historiques (CRH, UMR 8558) +Date : 2022-10-11 +Update : +""" + + +import re +import typing as t + +import peewee +from flask import url_for +from playhouse.sqlite_ext import FTS5Model, RowIDField, SearchField + +from app.app import db + + +class BaseModel(peewee.Model): + class Meta: + database = db + + +# db = SqliteDatabase('actes_princiers.db') +# from app.app import db + +class Institution(BaseModel): + id_institution = peewee.AutoField() + full_label = peewee.TextField() + inst_label = peewee.TextField() + art_inst = peewee.TextField() + inst_place = peewee.TextField() + inst_rank = peewee.TextField() + inst_type = peewee.TextField() + + class Meta: + database = db + db_table = 'Institution' + + +class State(BaseModel): + id_state = peewee.AutoField() + state_label = peewee.TextField() + + class Meta: + database = db + db_table = 'State' + + +class Production_place(BaseModel): + id_place = peewee.AutoField() + placename = peewee.TextField() + + class Meta: + database = db + db_table = 'Production_place' + + +class Diplo_type(BaseModel): + id_diplo_type = peewee.AutoField() + diplo_label = peewee.TextField() + + class Meta: + database = db + db_table = 'Diplo_type' + + +class Document(BaseModel): + id_document = peewee.AutoField() + inst_doc = peewee.ForeignKeyField(Institution, backref='documents') + collection_doc = peewee.TextField() + + class Meta: + database = db + db_table = 'Document' + + +class Acte(BaseModel): + id_acte = peewee.AutoField() + numb_acte = peewee.TextField() + date_time = peewee.TextField() # YYYY-MM-DD + date = peewee.TextField() # verbose + prod_place_acte = peewee.ForeignKeyField(Production_place, backref='actes') + analysis = peewee.TextField() + doc_acte = peewee.ForeignKeyField(Document, backref='actes') + ref_acte = peewee.TextField() # cote + state_doc = peewee.ForeignKeyField(State, backref='actes') + diplo_type_acte = peewee.ForeignKeyField(Diplo_type, backref='actes') + + class Meta: + database = db + db_table = 'Acte' + +class Individual(BaseModel): + id_indiv = peewee.AutoField() + name_indiv = peewee.TextField() + role_indiv = peewee.TextField() + + class Meta: + database = db + db_table = 'Individual' + +class Duke(BaseModel): + id_duke = peewee.AutoField() + house = peewee.TextField() + indiv_duke = peewee.ForeignKeyField(Individual, backref='dukes') + birth = peewee.TextField() + reign = peewee.TextField() + death = peewee.TextField() + + class Meta: + database = db + db_table = 'Duke' + +class Produced_by(BaseModel): + id_produced_by = peewee.AutoField() + produced_by_acte = peewee.ForeignKeyField(Acte, backref='produced_bys') + produced_by_prince = peewee.ForeignKeyField(Duke, backref='produced_bys') + + class Meta: + database = db + db_table = 'Produced_by' diff --git a/app/modeles/princes_db_tables.py b/app/modeles/princes_db_tables.py deleted file mode 100644 index 1fa5cd4..0000000 --- a/app/modeles/princes_db_tables.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- - -""" -Authors : Jean-Damien Généro -Affiliation : French National Center for Scientific Research (CNRS) -Assigned at the Centre de recherches historiques (CRH, UMR 8558) -Date : 2022-10-11 -Update : -""" - - -from peewee import * - - -db = SqliteDatabase('actes_princiers.db') -# from app.app import db - -class Institution(Model): - id_institution = IntegerField(primary_key=True) - full_label = TextField() - inst_label = TextField() - art_inst = TextField() - inst_place = TextField() - inst_rank = TextField() - inst_type = TextField() - - class Meta: - database = db - db_table = 'Institution' - - -class State(Model): - id_state = IntegerField(primary_key=True) - state_label = TextField() - - class Meta: - database = db - db_table = 'State' - - -class Production_place(Model): - id_place = IntegerField(primary_key=True) - placename = TextField() - - class Meta: - database = db - db_table = 'Production_place' - - -class Diplo_type(Model): - id_diplo_type = IntegerField(primary_key=True) - diplo_label = TextField() - - class Meta: - database = db - db_table = 'Diplo_type' - - -class Document(Model): - id_document = IntegerField(primary_key=True) - inst_doc = ForeignKeyField(Institution, backref='documents') - collection_doc = TextField() - - class Meta: - database = db - db_table = 'Document' - - -class Acte(Model): - id_acte = IntegerField(primary_key=True) - numb_acte = TextField() - date_time = TextField() # YYYY-MM-DD - date = TextField() # verbose - prod_place_acte = ForeignKeyField(Production_place, backref='actes') - analysis = TextField() - doc_acte = ForeignKeyField(Document, backref='actes') - ref_acte = TextField() # cote - state_doc = ForeignKeyField(State, backref='actes') - diplo_type_acte = ForeignKeyField(Diplo_type, backref='actes') - - class Meta: - database = db - db_table = 'Acte' - -class Individual(Model): - id_indiv = IntegerField(primary_key=True) - name_indiv = TextField() - role_indiv = TextField() - - class Meta: - database = db - db_table = 'Individual' - -class Duke(Model): - id_duke = IntegerField(primary_key=True) - house = TextField() - indiv_duke = ForeignKeyField(Individual, backref='dukes') - birth = TextField() - reign = TextField() - death = TextField() - - class Meta: - database = db - db_table = 'Duke' - -class Produced_by(Model): - id_produced_by = IntegerField(primary_key=True) - produced_by_acte = ForeignKeyField(Acte, backref='produced_bys') - produced_by_prince = ForeignKeyField(Duke, backref='produced_bys') - - class Meta: - database = db - db_table = 'Produced_by'