Add a sql_prepared() to pytest

It is similar to sql() except it enforces a prepare=True in the
execute()
pull/7288/head
Cédric Villemain 2023-10-31 14:45:40 +01:00
parent 60d1759d70
commit 5db3749e6c
1 changed files with 8 additions and 0 deletions

View File

@ -581,6 +581,14 @@ class QueryRunner(ABC):
with self.cur(**kwargs) as cur:
cur.execute(query, params=params)
def sql_prepared(self, query, params=None, **kwargs):
"""Run an SQL query, with prepare=True
This opens a new connection and closes it once the query is done
"""
with self.cur(**kwargs) as cur:
cur.execute(query, params=params, prepare=True)
def sql_row(self, query, params=None, allow_empty_result=False, **kwargs):
"""Run an SQL query that returns a single row and returns this row