4👍
✅
You sould use cursor
object to execute query:
cursor = connection.cursor()
sites_query = cursor.execute("SELECT domain FROM django_site")
sites_result = cursor.fetchall()
Don’t forget to close connection after get data:
cursor.close()
connection.close()
Source:stackexchange.com