Hello Dev community! I'm wanna show how to use from sql/mysql without models in django!
views.py
#we need to import connection module from django.db
from django.db import connection
#...
def home_view(request):
with connection.cursor() as sql:
sql.execute("UPDATE users SET last_time = %s WHERE user_id = %s", [user_date, user_session])
return render(request, "index.html")
Thank you!
Top comments (0)