Experiment in using psycopg2 instead of ogr pg driver.
Remove duplicate statement.
Use some dummy stuff and psycopg2 to rasterize without ogr pg driver.