hv-service/Wohnungen.py

37 lines
917 B
Python
Raw Normal View History

from dbpool import getConnection, getOne, getMany
2021-01-16 19:47:34 +01:00
def get_wohnungen():
return getMany("""
2021-01-16 19:47:34 +01:00
SELECT w.id as id,
2021-01-18 20:24:57 +01:00
w.objekt as objekt,
w.shortname as shortname,
2021-01-16 19:47:34 +01:00
w.flaeche as flaeche,
2021-01-18 20:24:57 +01:00
o.shortname as objekt_shortname
2021-01-16 19:47:34 +01:00
FROM wohnung w, objekt o
WHERE o.id = w.objekt
2021-01-17 14:45:11 +01:00
""", [], "Wohnung")
2021-01-16 19:47:34 +01:00
def get_wohnung(id=None):
return getOne("""
2021-01-16 19:47:34 +01:00
SELECT w.id as id,
2021-01-18 20:24:57 +01:00
w.objekt as objekt,
w.shortname as shortname,
2021-01-16 19:47:34 +01:00
w.flaeche as flaeche,
2021-01-18 20:24:57 +01:00
o.shortname as objekt_shortname
2021-01-16 19:47:34 +01:00
FROM wohnung w, objekt o
WHERE o.id = w.objekt AND
w.id = ?
""", (id, ), "Wohnung")
2021-01-18 18:37:19 +01:00
def get_wohnungen_by_objekt(id):
return getMany("""
SELECT w.id as id,
2021-01-18 20:24:57 +01:00
w.objekt as objekt,
w.shortname as shortname,
2021-01-18 18:37:19 +01:00
w.flaeche as flaeche,
2021-01-18 20:24:57 +01:00
o.shortname as objekt_shortname
2021-01-18 18:37:19 +01:00
FROM wohnung w, objekt o
WHERE o.id = w.objekt AND
o.id = ?
""", [ id ], "Wohnung")