Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to write manual querry in drf

from django.db import connection

def my_custom_sql(self):
    with connection.cursor() as cursor:
        cursor.execute("UPDATE bar SET foo = 1 WHERE baz = %s", [self.baz])
        cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz])
        row = cursor.fetchone()

    return row
Comment

how to write manual querry in drf

>>> lname = 'Doe'
>>> Person.objects.raw('SELECT * FROM myapp_person WHERE last_name = %s', [lname])
Comment

PREVIOUS NEXT
Code Example
Python :: pd.merge duplicate columns remove 
Python :: numpy 
Python :: print only strings in list python 
Python :: openpyxl get row from sheet 
Python :: how to use a for loop in python 
Python :: what is attribute in python 
Python :: CVE-2018-10933 
Python :: pytorch get non diag element 
Python :: close all tables python 
Python :: sns boxplot ylabelsize 
Python :: how to convert a string to a list python 
Python :: list comprehensions 
Python :: python loop with index 
Python :: index in the pool python 
Python :: how to create one list from 2d list python 
Python :: install nsml python 
Python :: cmake python interpreter 
Python :: python bubble plot 
Python :: import open3d Illegal instruction (core dumped) 
Python :: django base path on level up 
Python :: fetch last record from django model 
Python :: menu with icons tkinter 
Python :: how to access app.config globally in flask app 
Python :: create a thumbnail from video python 
Python :: add text in figure coordinatesp ython 
Python :: what is mustafa nickname 
Python :: python __add__ 
Python :: get value of property of object with name python 
Python :: how to add path to python in windows 
Python :: s=0 def sum(x,y): n=int(input("enter no. of terms") for i in range(n): l=int(input("enter no.")) s=s+l print(s) sum() 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =