I am new to sqlalchemy. I can create database tables by declarative mapping like this: This is fine. I added some data into both customer and invoice tables. So far so good. Next, I would try out automap_base on this existing database like this: When I ran the code, I got: AttributeError: type object ‘customer’ has no attribute ‘invoices’ What
Tag: declarative
SQLAlchemy: a better way for update with declarative?
Let’s say I have a user table in declarative mode: When I know user’s id without object loaded into session, I update such user like this: I dislike using User.__table__, should I stop worrying with that? Is there a better way to do this? Answer There’s also some update capability at the ORM level. It doesn’t handle any tricky cases