From: Mike Bayer Date: Wed, 16 Jul 2014 19:24:32 +0000 (-0400) Subject: - also add the alternate approach, name column distinctly from attribute name, X-Git-Tag: rel_0_9_7~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71cb95ef9f88cc5d578363ad688399a056e6d0f4;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - also add the alternate approach, name column distinctly from attribute name, ref #3129 --- diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py index a4f86c78a1..121285ab3a 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 ========================================