This content originally appeared on DEV Community and was authored by Manjiro
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!
This content originally appeared on DEV Community and was authored by Manjiro
Manjiro | Sciencx (2025-11-15T09:16:16+00:00) Django without models.. Retrieved from https://www.scien.cx/2025/11/15/django-without-models/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.