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
1from django.db import connection
2with connection.cursor() as cursor:
3 cursor.execute('TRUNCATE TABLE table_name CASCADE')