hv-service/Wohnungen.py

37 lines
917 B
Python

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