Execute a SQL query against the service and return results.
(
sql: str, conn: Connection, ignore_pg_exception=False
)
| 291 | conn.autocommit = True |
| 292 | |
| 293 | def query_with_conn( |
| 294 | sql: str, conn: Connection, ignore_pg_exception=False |
| 295 | ) -> list[list[Any]]: |
| 296 | """Execute a SQL query against the service and return results.""" |
| 297 | try: |
| 298 | with conn.cursor() as cursor: |
| 299 | LOGGER.info(f"> {sql}") |
| 300 | cursor.execute(sql) |
| 301 | return cursor.fetchall() |
| 302 | except DatabaseError: |
| 303 | if ignore_pg_exception: |
| 304 | return [] |
| 305 | else: |
| 306 | raise |
| 307 | |
| 308 | pid = query_with_conn("select pg_backend_pid();", conn)[0][0] |
| 309 | thread = Thread( |
no test coverage detected