I have a piece of Python code, that interacts with a PostgreSQL database via psycopg.
All literature warns against doing sql formatting by oneself, and recommends l
you wold use function curs.mogrify():
SQLstring = curs.mogrify('select name, age from people where name = %s;', ('ann',) )