params added to getMany

This commit is contained in:
Wolfgang Hottgenroth 2021-01-17 14:45:11 +01:00
parent 878ff31a52
commit b0daebe699
Signed by: wn
GPG Key ID: E49AF3B9EF6DD469
4 changed files with 5 additions and 5 deletions

View File

@ -19,7 +19,7 @@ SELECT m.id as id,
FROM wohnung w, objekt o, mieter m
WHERE o.id = w.objekt AND
w.id = m.wohnung
""")
""", [], "Mieter")
def get_mieter(id=None):
return getOne("""

View File

@ -1,7 +1,7 @@
from dbpool import getConnection, getMany, getOne
def get_objekte():
return getMany("SELECT id, shortname, flaeche FROM objekt")
return getMany("SELECT id, shortname, flaeche FROM objekt", [], "Objekt")
def get_objekt(id=None):
return getOne("SELECT id, shortname, flaeche FROM objekt WHERE id = ?",

View File

@ -9,7 +9,7 @@ SELECT w.id as id,
o.shortname as objekt
FROM wohnung w, objekt o
WHERE o.id = w.objekt
""")
""", [], "Wohnung")
def get_wohnung(id=None):
return getOne("""

View File

@ -28,12 +28,12 @@ def getConnection():
return pool.get_connection()
def getMany(stmt):
def getMany(stmt, params, objName):
try:
dbh = getConnection()
objs = []
cur = dbh.cursor(dictionary=True)
cur.execute(stmt)
cur.execute(stmt, params)
for obj in cur:
objs.append(obj)
return objs