Skip to content

Commit 6b493c4

Browse files
authored
Merge pull request #588 from DataIntegrationGroup/ngwmn-fix
feat: update SQL queries in ngwmn_helper.py for consistent quoting and improved readability
2 parents 925be66 + 8629b4e commit 6b493c4

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

services/ngwmn_helper.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,29 @@ def make_xml_response(db, sql, point_id, func):
2626

2727
rs = []
2828
for si in sql:
29-
3029
records = db.execute(text(si), {"point_id": point_id})
3130
rs.append(records.fetchall())
3231
return func(*rs)
3332

3433

3534
def make_lithology_response(point_id, db):
36-
sql = "select * from NMA_view_NGWMN_Lithology where PointID=:point_id"
35+
sql = 'select * from "NMA_view_NGWMN_Lithology" where "PointID"=:point_id'
3736
return make_xml_response(db, sql, point_id, lithology_xml)
3837

3938

4039
def make_well_construction_response(point_id, db):
41-
sql = "select * from NMA_view_NGWMN_WellConstruction where PointID=:point_id"
40+
sql = 'select * from "NMA_view_NGWMN_WellConstruction" where "PointID"=:point_id'
4241
return make_xml_response(db, sql, point_id, well_construction_xml)
4342

4443

4544
def make_waterlevels_response(point_id, db):
46-
sql = "select * from dbo.view_NGWMN_WaterLevels where PointID=:point_id order by DateMeasured"
45+
sql = (
46+
'select * from "NMA_view_NGWMN_WaterLevels" where "PointID"=:point_id '
47+
'order by "DateMeasured"'
48+
)
4749
sql2 = (
48-
"select * from NMA_WaterLevelsContinuous_Pressure_Daily where PointID=:point_id and QCed=1 order by "
49-
"DateMeasured"
50+
'select * from "NMA_WaterLevelsContinuous_Pressure_Daily" where "PointID"=:point_id and "QCed" is true '
51+
'order by "DateMeasured"'
5052
)
5153

5254
return make_xml_response(db, (sql, sql2), point_id, water_levels_xml2)

0 commit comments

Comments
 (0)