61 lines
1.6 KiB
Python
Executable file
61 lines
1.6 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Sat May 9 09:53:25 2020
|
|
|
|
@author: francois
|
|
"""
|
|
|
|
import questionary as qq
|
|
import choix_entite as ce
|
|
import questions_entite as qe
|
|
import questions_relations as qr
|
|
import dataset
|
|
|
|
|
|
def saisie_entite():
|
|
choix_entite = qq.prompt(ce.choix_entite('entite', 'entite'))['entite']
|
|
reponses = qq.prompt(qe.questions_entite[choix_entite])
|
|
try:
|
|
table = db[choix_entite]
|
|
table.insert(reponses)
|
|
for i in table.find(**reponses):
|
|
print(i)
|
|
except Exception as e:
|
|
print("Erreur dans l'insertion:"+str(e))
|
|
|
|
|
|
def saisie_relation():
|
|
reponses = qq.prompt(qr.questions_relations)
|
|
try:
|
|
table = db[reponses['entite1']+"_"+reponses['entite2']]
|
|
nom1 = db[reponses['entite1']].columns[0]
|
|
nom2 = db[reponses['entite2']].columns[0]
|
|
reponses_insert = {nom1: reponses['id_entite1'],
|
|
nom2: reponses['id_entite2'],
|
|
'description': reponses['description']}
|
|
table.insert(reponses_insert)
|
|
for i in table.find(**reponses_insert):
|
|
print(i)
|
|
except Exception as e:
|
|
print("Erreur dans l'insertion:"+str(e))
|
|
|
|
|
|
psql_string = 'postgresql://etatdulibre:etatdulibre@0.0.0.0/etatdulibre'
|
|
db = dataset.connect(psql_string)
|
|
|
|
quitter = 0
|
|
while quitter == 0:
|
|
m0 = qq.select(
|
|
"Entité ou relation?",
|
|
choices=[
|
|
'entite',
|
|
'relation',
|
|
'quitter'
|
|
]).ask()
|
|
if m0 == 'entite':
|
|
saisie_entite()
|
|
elif m0 == 'relation':
|
|
saisie_relation()
|
|
else:
|
|
quitter = 1
|