python - How can I view queries used for .create or .save without executing -
i want able retrieve sql statement being executed when calling
mymodel(**kawrgs).save()
or
mymodel.objects.create(**kwargs)
but without creating object in database. know can access queries via django.db.connection.queries
and querysetobject.sql
, , guess using transactions in way may useful, seems bit on head.
any suggestions?
thanks!
a.
you figure out method called in inner workings of save()
or create()
run final sql statement against database (probably in db backend cursor.execute()
) , use mock library prevent being executed , capture it's arguments instead.
Comments
Post a Comment