Tuesday, November 6, 2018

My developers have run amok

My developers, who have come from ColdFusion, are fond of this:

cursor = connection.cursor()
cursor.execute()
data = [r for r in cursor]
return render(request, some_template_name, {'data': data})

The problem with this is that the database cursor reference will be leaked.

How do I integrate into a unit test environment (single-threaded, single-process), a check for no outstanding cursors?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f3a0682e-b36a-45ff-8f73-95628f231ebf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment