Is there a way to make the following insert statement work by changing
something in the Event object's definition? Note I've simplified the
example, the reasons for using the core constructs in the first place are
to use postgres ON CONFLICT directives with it otherwise yes I could simply
use the ORM where the synonyms would work fine.
class Event(Base):
id = Column(BigInteger, primary_key=True)
start_date = Column(DateTime)
start_time = synonym('start_date')
dbsession.execute(insert(Event.__table__).values(start_time=datetime.utcnow()).returning(Event.id)).scalar()
Error raised, presumably because a core insert construct doesn't support
column aliases defined at the mapper level?
sqlalchemy.exc.CompileError: Unconsumed column names: start_time
Thanks!
- Michael
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/e08eadbd-ade9-4ee5-bcc0-3609ecd959f0n%40googlegroups.com.