summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-06-14 20:13:26 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-06-14 20:13:26 +0000
commitaa8ddf7d356e7ea8c100cca18bb49e3bd820ca31 (patch)
tree5d9a2efbfc0d4bad6949a37e4db918293650d36f /lib
parent85c62d8473dc9a4116716918afb928ffaff8cac1 (diff)
parentbe9937d385a74560b65c6ab525f13bc68a5041c1 (diff)
downloadsqlalchemy-aa8ddf7d356e7ea8c100cca18bb49e3bd820ca31.tar.gz
Merge "Remove reflect=True in Base.prepare examples" into main
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/ext/automap.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py
index 70d392187..19dadf29c 100644
--- a/lib/sqlalchemy/ext/automap.py
+++ b/lib/sqlalchemy/ext/automap.py
@@ -42,7 +42,7 @@ asking it to reflect the schema and produce mappings::
engine = create_engine("sqlite:///mydatabase.db")
# reflect the tables
- Base.prepare(engine, reflect=True)
+ Base.prepare(autoload_with=engine)
# mapped classes are now created with names by default
# matching that of the table name.
@@ -153,7 +153,7 @@ established based on the table name we use. If our schema contains tables
# reflect
engine = create_engine("sqlite:///mydatabase.db")
- Base.prepare(engine, reflect=True)
+ Base.prepare(autoload_with=engine)
# we still have Address generated from the tablename "address",
# but User is the same as Base.classes.User now
@@ -217,7 +217,7 @@ scheme for class names and a "pluralizer" for collection names using the
engine = create_engine("sqlite:///mydatabase.db")
- Base.prepare(engine, reflect=True,
+ Base.prepare(autoload_with=engine,
classname_for_table=camelize_classname,
name_for_collection_relationship=pluralize_collection
)
@@ -335,7 +335,7 @@ options along to all one-to-many relationships::
Base = automap_base()
engine = create_engine("sqlite:///mydatabase.db")
- Base.prepare(engine, reflect=True,
+ Base.prepare(autoload_with=engine,
generate_relationship=_gen_relationship)
Many-to-Many relationships
@@ -466,7 +466,7 @@ We can resolve this conflict by using an underscore as follows::
return name
- Base.prepare(engine, reflect=True,
+ Base.prepare(autoload_with=engine,
name_for_scalar_relationship=name_for_scalar_relationship)
Alternatively, we can change the name on the column side. The columns
@@ -480,7 +480,7 @@ to a new name::
__tablename__ = 'table_b'
_table_a = Column('table_a', ForeignKey('table_a.id'))
- Base.prepare(engine, reflect=True)
+ Base.prepare(autoload_with=engine)
Using Automap with Explicit Declarations
@@ -549,7 +549,7 @@ be applied as::
column_info['key'] = "attr_%s" % column_info['name'].lower()
# run reflection
- Base.prepare(engine, reflect=True)
+ Base.prepare(autoload_with=engine)
.. versionadded:: 1.4.0b2 the :meth:`_events.DDLEvents.column_reflect` event
may be applied to a :class:`_schema.MetaData` object.
@@ -745,7 +745,7 @@ class AutomapBase:
are present under the name they were given, e.g.::
Base = automap_base()
- Base.prepare(engine=some_engine, reflect=True)
+ Base.prepare(autoload_with=some_engine)
User, Address = Base.classes.User, Base.classes.Address