def populate_temp_table(self, cursor: connection.cursor, temp_table: TempTableName) -> None: sql_template = "INSERT INTO {0} SELECT * FROM ({1}) AS {0}_contents;" with Timer(f"Populate '{temp_table.value}'"): cursor.execute( sql_template.format(temp_table.value, TEMP_TABLE_CONTENTS[temp_table]))
def dictfetchall(cursor: connection.cursor) -> List[Dict[str, Any]]: "Returns all rows from a cursor as a dict" desc = cursor.description return [ dict(list(zip([col[0] for col in desc], row))) for row in cursor.fetchall() ]