Esempio n. 1
0
 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]))
Esempio n. 2
0
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()
    ]
Esempio n. 3
0
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()
    ]