hv-service/Wohnungen.py

25 lines
580 B
Python

from dbpool import getConnection, getOne, getMany
def get_wohnungen():
return getMany("""
SELECT w.id as id,
w.objekt as objekt_id,
w.shortname as wohnung,
w.flaeche as flaeche,
o.shortname as objekt
FROM wohnung w, objekt o
WHERE o.id = w.objekt
""")
def get_wohnung(id=None):
return getOne("""
SELECT w.id as id,
w.objekt as objekt_id,
w.shortname as wohnung,
w.flaeche as flaeche,
o.shortname as objekt
FROM wohnung w, objekt o
WHERE o.id = w.objekt AND
w.id = ?
""", (id, ), "Wohnung")