Reputation:
Im looking for a way to fetch some data to display to the user.(Run a raw sql query like)
select * from "DB-table" where Name like "%blabla%" and Year like "%2020%"
My problem is that the "DB-table" lives in my database but its already populated with important data which is not related to some model in my django-app. Its a standalone table with a lot of data. How can i refer to that table from my views.py file?
Upvotes: 1
Views: 405
Reputation:
Clearly my question was not so hard..But as im new to django and python i overcomplicated things. I managed to fetch the data i wanted using something like
with connection.cursor() as cursor:
cursor.execute("SELECT * FROM 'Nvd-data'")
res = cursor.fetchall()
print(res)
For more advanced queries i think django documentation is fine.Hope that silly question helps someone
Upvotes: 2