Reputation: 53943
I'm running a fairly large insert into select
query in Django, which I do using
MyModel.objects.raw(insert_query)
But that doesn't do anything since queries seem to only be run when something is taken from it's result. So when I do this it runs the query
MyModel.objects.raw(insert_query)[0]
but also gives an error:
TypeError: 'NoneType' object is not iterable
I can run the queries using
from django.db import connection
with connection.cursor() as cursor:
cursor.execute(insert_query)
But that doesn't give me any feedback on what it actually did.
Is there a way that I can run the raw query and get the number of records it inserted or a possible error if that occurred?
Upvotes: 0
Views: 276