Thread: Use of .mogrify
Hi All, I just stumbled across this conversation: http://permalink.gmane.org/gmane.comp.python.db.psycopg.devel/4775 Is .mogrify still just for debugging usage? I have a query generated by Django's ORM that I would like to execute as plain SQL (because I will wrap some SQL around it). Cheers, Tobias
Attachment
On 04/02/2014 05:00 PM, Tobias Fielitz wrote: > Hi All, > > I just stumbled across this conversation: > http://permalink.gmane.org/gmane.comp.python.db.psycopg.devel/4775 > > Is .mogrify still just for debugging usage? > > I have a query generated by Django's ORM that I would like to execute as > plain SQL (because I will wrap some SQL around it). Any reason you cannot just put it into execute()? > > Cheers, > Tobias > > > -- Adrian Klaver adrian.klaver@aklaver.com
On Thu, Apr 3, 2014 at 1:00 AM, Tobias Fielitz <tobias@streethawk.com> wrote: > Hi All, > > I just stumbled across this conversation: > http://permalink.gmane.org/gmane.comp.python.db.psycopg.devel/4775 > > Is .mogrify still just for debugging usage? That message is still valid: currently mogrify does what you expect (actually better than it used to do in 2008). But in the future we don't guarantee that (actually, if we move to sending parameters to the server, new cursor classes may not have a mogrify method at all). > I have a query generated by Django's ORM that I would like to execute as > plain SQL (because I will wrap some SQL around it). Why don't you wrap the SQL around the query with placeholders and then pass the parameters? -- Daniele