-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBD.py
More file actions
35 lines (29 loc) · 1.02 KB
/
BD.py
File metadata and controls
35 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sqlite3
from Activites import Activites
import json
"""conn = sqlite3.connect('installations.db')
c = conn.cursor()
c.execute("DROP TABLE IF EXISTS installations")
c.execute('''CREATE TABLE installations
(InsNumeroInstall integer,ComLib text,ComInsee integer,InsCodePostal integer)''')
c.execute("DROP TABLE IF EXISTS equipements")
c.execute('''CREATE TABLE equipements
(ComInsee integer,ComLib text,InsNumeroInstall integer,EquipementId integer,EquNom text)''')
c.execute("DROP TABLE IF EXISTS activites")
c.execute('''CREATE TABLE activites
(ComInsee integer,ComLib text,EquipementId integer,ActCode integer)''')
conn.commit()
conn.close()
def initBDEquipCSV(filepath) :
f=open(filepath,'r');
while(true) :
l=readline()
if(l==None) break;
else :
pass"""
#Exemple code JSON
json_file = "BD/Activites.json"
file_data = json.load(open(json_file))
for item in file_data["data"]:
inst=Activites(item["ComInsee"],item["ComLib"],item["EquipementId"],item["ActCode"])
print (inst)