Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

raw query in django

from django.db import connection

sql = 'SELECT * FROM db1.a AS a
       JOIN db2.b AS b 
       ON b.some_id = a.id
       WHERE a.name = %s'
cursor = connection.cursor()
try:
      cursor.execute(sql, ['localhost'])
      row = cursor.fetchall()
except Exception as e:
      cursor.close
Comment

How can I see the raw SQL queries Django

$ python manage.py sqlmigrate <app_name> <migration_number>

#Ex: $ python manage.py sqlmigrate polls 0001
# It will show the sql quires of specific migrations
Comment

PREVIOUS NEXT
Code Example
Python :: gaussian filter 
Python :: Comparison of two csv file and output with differences? 
Python :: python read binary 
Python :: pandas difference between rows in a column 
Python :: typing pandas dataframe 
Python :: react-native-dropdown-picker 
Python :: Using a list with index and column names to Convert List to Dataframe 
Python :: python list of whole numbers 
Python :: closedxml hide column 
Python :: python sys.argv exception 
Python :: python number of elements in list of lists 
Python :: matplotlib larger chart 
Python :: python for android 
Python :: how do a plot on matplotlib python 
Python :: resize cmd using python 
Python :: nltk bigrams 
Python :: len function in python 
Python :: pyton count number of character in a word 
Python :: Python program to count Even and Odd numbers using lambda 
Python :: créer fonction python 
Python :: savefig matplotlib python 
Python :: tf.reduce_sum() 
Python :: python command line start server 
Python :: pip install pandas Getting requirements to build wheel 
Python :: plt tickpad 
Python :: how to install django 
Python :: python regular expressions 
Python :: append multiple values to 2d list python 
Python :: bar plot 
Python :: python map() 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =