diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-16 15:24:32 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-16 15:24:32 -0400 |
commit | 4020f2f440b17b3637c19ac37a394646e0ddd21a (patch) | |
tree | b54ea6583cd79f2dad18b8d0e420c35aa94875ca /lib | |
parent | 0083075b8e460b4558cd241e32d168a2db26ab96 (diff) | |
download | sqlalchemy-4020f2f440b17b3637c19ac37a394646e0ddd21a.tar.gz |
- also add the alternate approach, name column distinctly from attribute name,
ref #3129
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 ======================================== |