From 151881617b7d5a720b7e1c4780394826ec535af9 Mon Sep 17 00:00:00 2001 From: kevincaires Date: Sun, 14 Aug 2022 11:46:04 -0300 Subject: [PATCH] CHANGE content response. --- utils/database.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/database.py b/utils/database.py index baf51db..2edb9d6 100644 --- a/utils/database.py +++ b/utils/database.py @@ -2,6 +2,8 @@ Database utils module. """ import logging +from collections import namedtuple + import MySQLdb from settings.config import MYSQL_CONFIG @@ -74,8 +76,11 @@ def get_quote() -> tuple: select quote, user, id from neeble_quotes; ''' - response = None + response = [] + obj = namedtuple('Quotes', ['quote', 'user', 'id']) + with Cursor(MYSQL_CONFIG) as cursor: cursor.execute(_sql) response = cursor.fetchall() - return response + + return tuple(obj(*r) for r in response)