Si su tabla se define así:
from datetime import datetime
from sqlalchemy import *
from sqlalchemy.dialects.postgresql import ARRAY
meta = MetaData()
surveys_table = Table('surveys', meta,
Column('surveys_id', Integer, primary_key=True),
Column('questions_ids_ordered', ARRAY(Integer)),
Column('created_at', DateTime, nullable=False, default=datetime.utcnow)
)
Luego, simplemente puede actualizar su matriz de la siguiente manera (funciona con psycopg2):
engine = create_engine('postgresql://localhost')
conn = engine.connect()
u = surveys_table.update().where(surveys_table.c.id == 46).\
values(questions_ids_ordered=[237, 238, 239, 240, 241, 242, 243])
conn.execute(u)
conn.close()
O, si lo prefiere, escriba SQL sin formato usando text()
construir:
from sqlalchemy.sql import text
with engine.connect() as conn:
u = text('UPDATE surveys SET questions_ids_ordered = :q WHERE id = :id')
conn.execute(u, q=[237, 238, 239, 240, 241, 242, 243], id=46)