Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SqlExecutor:
- def dictfetchall(self, cursor):
- # "Return all rows from a cursor as a dict"
- columns = [col[0] for col in cursor.description]
- return [
- dict(zip(columns, row))
- for row in cursor.fetchall()
- ]
- def execute(self, sql):
- with connection.cursor() as c:
- c.execute(sql)
- rows = self.dictfetchall(c)
- return rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement