]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
import `declarative_base` and `select` from correct modules
authorDoctor <thirvondukr@gmail.com>
Thu, 28 Apr 2022 05:01:04 +0000 (08:01 +0300)
committerDoctor <thirvondukr@gmail.com>
Thu, 28 Apr 2022 05:01:04 +0000 (08:01 +0300)
doc/build/orm/backref.rst
doc/build/orm/basic_relationships.rst
doc/build/orm/extensions/asyncio.rst
doc/build/orm/extensions/mypy.rst

index 4b500bd9ca39b4c44e7f9872953a05d70c4d9cdf..24587003ea5d79478bbed915a9b4783128f84beb 100644 (file)
@@ -8,8 +8,7 @@ mentioned throughout many of the examples here.   What does it actually do ?   L
 with the canonical ``User`` and ``Address`` scenario::
 
     from sqlalchemy import Column, ForeignKey, Integer, String
-    from sqlalchemy.ext.declarative import declarative_base
-    from sqlalchemy.orm import relationship
+    from sqlalchemy.orm import declarative_base, relationship
 
     Base = declarative_base()
 
@@ -38,8 +37,7 @@ of an event listener on both sides which will mirror attribute operations
 in both directions.   The above configuration is equivalent to::
 
     from sqlalchemy import Column, ForeignKey, Integer, String
-    from sqlalchemy.ext.declarative import declarative_base
-    from sqlalchemy.orm import relationship
+    from sqlalchemy.orm import declarative_base, relationship
 
     Base = declarative_base()
 
@@ -124,8 +122,7 @@ or a one-to-many or many-to-one which has a :paramref:`_orm.relationship.primary
 as if we limited the list of ``Address`` objects to those which start with "tony"::
 
     from sqlalchemy import Column, ForeignKey, Integer, String
-    from sqlalchemy.ext.declarative import declarative_base
-    from sqlalchemy.orm import relationship
+    from sqlalchemy.orm import declarative_base, relationship
 
     Base = declarative_base()
 
@@ -150,7 +147,6 @@ as if we limited the list of ``Address`` objects to those which start with "tony
         email = Column(String)
         user_id = Column(Integer, ForeignKey("user.id"))
 
-
 We can observe, by inspecting the resulting property, that both sides
 of the relationship have this join condition applied::
 
@@ -257,8 +253,7 @@ of the "backref" behavior on the Python side by using two separate :func:`_orm.r
 placing :paramref:`_orm.relationship.back_populates` only on one side::
 
     from sqlalchemy import Column, ForeignKey, Integer, String
-    from sqlalchemy.ext.declarative import declarative_base
-    from sqlalchemy.orm import relationship
+    from sqlalchemy.orm import declarative_base, relationship
 
     Base = declarative_base()
 
index dfc1c0904323e51ceed625fcea3582e65bc6c9cc..ad57d4ca0791bbad2728313bc88dd80f59e55851 100644 (file)
@@ -8,12 +8,10 @@ A quick walkthrough of the basic relational patterns.
 The imports used for each of the following sections is as follows::
 
     from sqlalchemy import Column, ForeignKey, Integer, Table
-    from sqlalchemy.ext.declarative import declarative_base
-    from sqlalchemy.orm import relationship
+    from sqlalchemy.orm import declarative_base, relationship
 
     Base = declarative_base()
 
-
 .. _relationship_patterns_o2m:
 
 One To Many
index 64732d1b3196c952165b9ff3be9156cbba030164..9c0428280dfabe43c16bc4a11896ba2c8eaa4761 100644 (file)
@@ -142,9 +142,16 @@ illustrates a complete example including mapper and session configuration::
 
     import asyncio
 
-    from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, func
+    from sqlalchemy import (
+        Column,
+        DateTime,
+        ForeignKey,
+        Integer,
+        String,
+        func,
+        select,
+    )
     from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
-    from sqlalchemy.future import select
     from sqlalchemy.orm import declarative_base, relationship, selectinload
 
     Base = declarative_base()
@@ -382,6 +389,7 @@ attribute accesses within a separate function::
 
     import asyncio
 
+    from sqlalchemy import select
     from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
 
 
index 2fe23331138c257bd12ee1ecfce80c5c2b847e6f..9d1d909a88d0cfb988b26136073b4ddfabbd2d00 100644 (file)
@@ -147,8 +147,7 @@ definition and Python code passed to the Mypy tool is equivalent to the
 following::
 
     from sqlalchemy import Column, Integer, String, select
-    from sqlalchemy.orm import Mapped
-    from sqlalchemy.orm.decl_api import DeclarativeMeta
+    from sqlalchemy.orm import DeclarativeMeta, Mapped
 
 
     class Base(metaclass=DeclarativeMeta):