def display_Equipements(self): """ Exposes the service at localhost:8080/display_Equipements """ html = "" database = bd.Database('service/M4105C.db') eqs = database.read_Equipement() html += ''' <h2>Information des installations</h2> <table> <tr> <th>NumeroInstall</th> <th>ComLib</th> <th>ComInsee</th> </tr>\n''' for i in eqs: if (i != []): html += '''<tr>\n <td>''' + str(i[0]) + '''</td> <td>''' + str(i[1]) + '''</td> <td>''' + str(i[2]) + '''</td> </tr>''' html += '''</table>''' return html
def display_Activites(self): """ Exposes the service at localhost:8080/display_Activites """ html = "" database = bd.Database('service/M4105C.db') act = database.read_Activite() html += ''' <h2>Information des activites</h2> <table> <tr> <th>EquipementId</th> <th>ComInsee</th> <th>ActCode</th> <th>ActLib</th> <th>ComLib</th> </tr>\n''' for i in act: if (i != []): html += '''<tr>\n <td>''' + str(i[0]) + '''</td> <td>''' + str(i[1]) + '''</td> <td>''' + str(i[2]) + '''</td> <td>''' + i[3] + '''</td> <td>''' + i[4] + '''</td> </tr>''' html += '''</table>''' return html
def requestActivity(self, commune): """ Exposes the service at localhost:8080/requestActivity """ view = Template(filename="view/template.html", lookup=lookup) database = db.Database("db/test.db") results = database.requestActivity(commune) return view.render(rows=results)
def form_activity(self): """ Exposes the service at localhost:8080/form_activity """ view = Template(filename="view/template2.html", lookup=lookup) database = db.Database("db/test.db") results = database.requestCity() return view.render(rows=results)
def show_all(self, table): """ Exposes the service at localhost:8080/show_all/table """ view = Template(filename="view/template.html", lookup=lookup) database = db.Database("db/test.db") results = database.selectAll(table) return view.render(rows=results)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import Modele.Installation as inst import Modele.Equipement as equ import Modele.Activite as act import service.database as db installs = inst.parse_json_installation("fichierJson/Installation.json") equs = equ.parse_json_equipment("fichierJson/Equipement.json") acts = act.parse_json_activite("fichierJson/Activite.json") database = db.Database("service/M4105C.db") database.createNew("Installation", installs[0]) database.insert(installs) #database.selectAll("installation") database.createNew("Equipement", equs[0]) database.insert(equs) #database.selectAll("equipement") database.createNew("Activite", acts[0]) database.insert(acts) database.commit() database.close()
# -*- coding: utf-8 -*- '''Equivalent at the main for create the database''' import modele.installation as ins import modele.equipement as eq import modele.activite as act from progressbar import * import service.database as db '''Call of function to parse the JSON''' inst = ins.parse_json_installation("ressource/installation.json") equip = eq.parse_json_equipement("ressource/equipement.json") acts = act.parse_json_activite("ressource/activite.json") '''Call the database''' database = db.Database("db/test.db") '''Call function to create table of installation''' database.create("installation", inst[0]) '''Setting the progressbar of insertion at the database''' pbar = ProgressBar(widgets=[ 'Insert into installations to database: ', Percentage(), ' ', ETA() ]) for elem in pbar(inst): database.insertOne(elem) pbar = ProgressBar( widgets=['Insert into equipement to database: ', Percentage(), ' ', ETA()]) database.create("equipement", equip[0]) for elem in pbar(equip): database.insertOne(elem)