Postgresql implicitly defines several columns on every table, such as xmax
and ctid
(see docs).
Assuming my SQLALchemy table definition does not specify these columns, is there a way to select them using the core sql functionality (i.e. not the ORM part of SA)?
The following does not work as xmax
is not explicitly defined in the table definition.
table = sa.Table(
"mytable",
metadata,
sa.Column("col_a", sa.BIGINT),
sa.Column("date", sa.DATE),
)
s = sa.select([table.c.xmax])
result = engine.execute(s)
Specifically my requirement is to reference xmax
in the returning
clause of an upsert.
insert(mytable).returning((mytable.c.xmax == 0).label("inserted"))