diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/ext/automap.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py index a4f86c78a..121285ab3 100644 --- a/lib/sqlalchemy/ext/automap.py +++ b/lib/sqlalchemy/ext/automap.py @@ -432,6 +432,20 @@ We can resolve this conflict by using an underscore as follows:: Base.prepare(engine, reflect=True, name_for_scalar_relationship=name_for_scalar_relationship) +Alternatively, we can change the name on the column side. The columns +that are mapped can be modified using the technique described at +:ref:`mapper_column_distinct_names`, by assigning the column explicitly +to a new name:: + + Base = automap_base() + + class TableB(Base): + __tablename__ = 'table_b' + _table_a = Column('table_a', ForeignKey('table_a.id')) + + Base.prepare(engine, reflect=True) + + Using Automap with Explicit Declarations ======================================== |