from psycopg2.extensions import AsIs
import psycopg2
connection = psycopg2.connect(database='db', user='user')
cur = connection.cursor()
cur.mogrify('CREATE USER %s PASSWORD %s', (AsIs('someuser'), AsIs(
    'somepassword')))
"""CREATE USER someuser PASSWORD somepassword"""
Python добавляет «E» в строку