1from django.db import connection
2
3sql = 'SELECT * FROM db1.a AS a
4 JOIN db2.b AS b
5 ON b.some_id = a.id
6 WHERE a.name = %s'
7cursor = connection.cursor()
8try:
9 cursor.execute(sql, ['localhost'])
10 row = cursor.fetchall()
11except Exception as e:
12 cursor.close
1$ python manage.py sqlmigrate <app_name> <migration_number>
2
3#Ex: $ python manage.py sqlmigrate polls 0001
4# It will show the sql quires of specific migrations
5