Dear all,
I am using:
sqlalchemy==1.3.18
psycopg2==2.8.4
connection url schema: "postgresql+psycopg2://..."
postgres 10.x
when I define an explicit AutomapBase-derived model for
'sqa_global_context' table with only the primary key, I expected that
running `Base.metadata.reflect(bind=database.ENGINE,
only=['sqa_global_context']); Base.prepare()` would backfill missing
columns and relationships in that table. However, after running
`Base.prepare(engine, reflect=True)`, the missing columns and relationships
are not populated in my table.
My code looks like this:
```
_AutomapBase = automap.automap_base()
class Model1(_AutomapBase):
__tablename__ = 'model1"
id_ = sa.Column('id', sa.Integer, primary_key=True, autoincrement=True,
key='id_')
tag = sa.Column(sa.String())
_AutomapBase.metadata.reflect(bind=ENGINE, only=['model1'],
extend_existing=True)
_AutomapBase.prepare()
```
I get the exception `ArgumentError: Only one Column may be marked
autoincrement=True, found both id and id.` when I run the following insert:
```
row = Model1(tag='tag1')
orm_session.add(attempt)
orm_session.flush()
```
I suspect this has something to do with the combination of the explicit
definition of the `id_` column and reflection, but don't know how to fix. I
really need to keep the explicit `id_` descriptor and shouldn't rename it
to `id` because that's a reserved python word.
Please help. Many thanks in advance!
--
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/426d0281-27ee-448d-829f-72f137532fd2n%40googlegroups.com.