I have two databases in my django application. One is default and another is secondary. When I tried the following code it always returns data from the default database.
from django.db import connection
def my_custom_sql(self):
cursor = connection.cursor()
cursor.execute("SELECT * FROM accounts_account where id=%s", [self.id])
row = cursor.fetchall()
return row
I want to execute the query in second database.