import psycopg2
from psycopg2.extensions import AsIs
conn = psycopg2.connect('host=localhost4 port=5432 dbname=cpn')
cursor = conn.cursor()
query = 'alter table t add column %s text'
row1 = 'col1', 'col2'
for c in row1:
    cursor.execute(query, (AsIs(c),))
conn.commit()
Pass column name as parameter to PostgreSQL using psycopg2