python - psycopg - Get formatted sql instead of executing -


i have piece of python code, interacts postgresql database via psycopg.

all literature warns against doing sql formatting oneself, , recommends letting driver it. e.g.:

cur.execute('select name, age people name = %s;', ('ann',) ) 

the driver formats sql string. let's don't want execute anything, want formatted sql string. there functionality getting formatted sql in psycopg module?

you wold use function curs.mogrify():

sqlstring = curs.mogrify('select name, age people name = %s;', ('ann',) ) 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -