Core insert and named columns

13 views
Skip to first unread message

Tomas Pavlovsky

unread,
Oct 20, 2021, 6:31:01 AMOct 20
to sqlalchemy
Hi,

class A():
 id = Column('object_id", Integer, primary_key=True)
 field = Column(Integer, primary_key=True)

insert(A).values(**{id:1, field:3})

sqlalchemy.exc.CompileError: Unconsumed column names: id

It is normal behavior or not?
Thanks

Mike Bayer

unread,
Oct 20, 2021, 1:02:03 PMOct 20
to noreply-spamdigest via sqlalchemy
for the moment yes, because there is no ORM overlay for the insert() construct.    the case below should be improved however.

reliable way is to use the attributes:

stmt = insert(A).values({A.id: 1, A.field: 3})



--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.

Mike Bayer

unread,
Oct 20, 2021, 1:05:46 PMOct 20
to noreply-spamdigest via sqlalchemy

Tomas Pavlovsky

unread,
Oct 21, 2021, 4:41:36 AMOct 21
to sqlalchemy
Ok, thank you. 
Reply all
Reply to author
Forward
0 new messages