forked from osm-fr/osm-vs-fantoir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
anomalies_fantoir.py
executable file
·34 lines (27 loc) · 1.05 KB
/
anomalies_fantoir.py
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
#!./venv37/bin/python
# -*- coding: utf-8 -*-
import cgi
import cgitb
# import os.path
import sys
import json
import db
def get_data_from_pg(conn,data_type,substitutions):
with conn.cursor() as cur:
with open(f"sql/{data_type}.sql",'r') as fq:
str_query = fq.read()
for s in substitutions:
str_query = str_query.replace(s[0],s[1])
# print(str_query)
cur.execute(str_query)
return cur.fetchall()
params = cgi.FieldStorage()
dept = params['dept'].value
# dept = '29'
data = get_data_from_pg(db.bano_cache,'anomalies_fantoir',[['__dept__',dept]])
# data = get_data_from_pg(db.bano_cache,'anomalies_fantoir_point',[['__dept__',dept]])
# data_ligne = get_data(db.bano_cache,'anomalies_fantoir_ligne',[[dept,'__dept__']])
# data_polygone = get_data(db.bano_cache,'anomalies_fantoir_polygone',[[dept,'__dept__']])
# data_relation = get_data(db.bano_cache,'anomalies_fantoir_relation',[[dept,'__dept__']])
print("Content-Type: application/json\n")
print(json.JSONEncoder().encode(data))