Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 277 for get_db (0.24 sec)

  1. docs_src/sql_databases/sql_app/tests/test_sql_app.py

    from ..database import Base
    from ..main import app, get_db
    
    SQLALCHEMY_DATABASE_URL = "sqlite://"
    
    engine = create_engine(
        SQLALCHEMY_DATABASE_URL,
        connect_args={"check_same_thread": False},
        poolclass=StaticPool,
    )
    TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
    
    
    Base.metadata.create_all(bind=engine)
    
    
    def override_get_db():
        try:
            db = TestingSessionLocal()
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Jun 22 11:20:12 GMT 2023
    - 1.2K bytes
    - Viewed (0)
  2. docs/en/docs/advanced/testing-database.md

    ```Python hl_lines="19-24  27"
    {!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
    ```
    
    !!! tip
        The code for `override_get_db()` is almost exactly the same as for `get_db()`, but in `override_get_db()` we use the `TestingSessionLocal` for the testing database instead.
    
    ## Test the app
    
    Then we can just test the app as normally.
    
    ```Python hl_lines="32-47"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 3.5K bytes
    - Viewed (0)
  3. docs/zh/docs/advanced/testing-database.md

    ```
    
    ## 覆盖依赖项
    
    接下来,创建覆盖依赖项,并为应用添加覆盖内容。
    
    ```Python hl_lines="19-24  27"
    {!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
    ```
    
    !!! tip "提示"
    
        `overrider_get_db()` 与 `get_db` 的代码几乎完全一样,只是 `overrider_get_db` 中使用测试数据库的 `TestingSessionLocal`。
    
    ## 测试应用
    
    然后,就可以正常测试了。
    
    ```Python hl_lines="32-47"
    {!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Jan 28 18:09:26 GMT 2024
    - 2.8K bytes
    - Viewed (0)
  4. docs/em/docs/how-to/sql-databases-peewee.md

    👈, 👥 💪 ✍ ➕1️⃣ `async` 🔗 `reset_db_state()` 👈 ⚙️ 🎧-🔗 `get_db()`. ⚫️ 🔜 ⚒ 💲 🔑 🔢 (⏮️ 🔢 `dict`) 👈 🔜 ⚙️ 💽 🇵🇸 🎂 📨. & ⤴️ 🔗 `get_db()` 🔜 🏪 ⚫️ 💽 🇵🇸 (🔗, 💵, ♒️).
    
    ```Python hl_lines="18-20"
    {!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
    ```
    
    **⏭ 📨**, 👥 🔜 ⏲ 👈 🔑 🔢 🔄 `async` 🔗 `reset_db_state()` & ⤴️ ✍ 🆕 🔗 `get_db()` 🔗, 👈 🆕 📨 🔜 ✔️ 🚮 👍 💽 🇵🇸 (🔗, 💵, ♒️).
    
    !!! tip
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 19.2K bytes
    - Viewed (0)
  5. docs/en/docs/how-to/sql-databases-peewee.md

    For that, we need to create another `async` dependency `reset_db_state()` that is used as a sub-dependency in `get_db()`. It will set the value for the context variable (with just a default `dict`) that will be used as the database state for the whole request. And then the dependency `get_db()` will store in it the database state (connection, transactions, etc).
    
    ```Python hl_lines="18-20"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 16 13:23:25 GMT 2024
    - 23.6K bytes
    - Viewed (1)
  6. docs/zh/docs/tutorial/sql-databases.md

    ```
    
    然后我们应该声明*路径操作函数*和不带 的依赖关系`async def`,只需使用普通的`def`,如下:
    
    ```Python hl_lines="2"
    @app.get("/users/{user_id}", response_model=schemas.User)
    def read_user(user_id: int, db: Session = Depends(get_db)):
        db_user = crud.get_user(db, user_id=user_id)
        ...
    ```
    
    !!! info
        如果您需要异步连接到关系数据库,请参阅[Async SQL (Relational) Databases](https://fastapi.tiangolo.com/zh/advanced/async-sql-databases/)
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 27K bytes
    - Viewed (0)
  7. docs/en/docs/tutorial/sql-databases.md

    ```Python hl_lines="2"
    @app.get("/users/{user_id}", response_model=schemas.User)
    def read_user(user_id: int, db: Session = Depends(get_db)):
        db_user = crud.get_user(db, user_id=user_id)
        ...
    ```
    
    !!! info
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 29.6K bytes
    - Viewed (0)
  8. docs/em/docs/tutorial/sql-databases.md

    ```
    
    ⤴️ 👥 🔜 📣 *➡ 🛠️ 🔢* & 🔗 🍵 `async def`, ⏮️ 😐 `def`,:
    
    ```Python hl_lines="2"
    @app.get("/users/{user_id}", response_model=schemas.User)
    def read_user(user_id: int, db: Session = Depends(get_db)):
        db_user = crud.get_user(db, user_id=user_id)
        ...
    ```
    
    !!! info
        🚥 👆 💪 🔗 👆 🔗 💽 🔁, 👀 [🔁 🗄 (🔗) 💽](../advanced/async-sql-databases.md){.internal-link target=_blank}.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 25.2K bytes
    - Viewed (1)
  9. maven-compat/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java

            return JDK_VERSION;
        }
    
        protected boolean canDetectActivation(Profile profile) {
            return profile.getActivation() != null
                    && profile.getActivation().getJdk() != null
                    && !profile.getActivation().getJdk().isEmpty();
        }
    Java
    - Registered: Sun May 05 03:35:11 GMT 2024
    - Last Modified: Thu Sep 14 11:48:15 GMT 2023
    - 3K bytes
    - Viewed (0)
  10. maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/profile/JdkVersionProfileActivator.java

    import org.apache.maven.api.services.model.ProfileActivator;
    
    /**
     * Determines profile activation based on the version of the current Java runtime.
     *
     * @see Activation#getJdk()
     */
    @Named("jdk-version")
    @Singleton
    public class JdkVersionProfileActivator implements ProfileActivator {
    
        private static final Pattern FILTER_1 = Pattern.compile("[^\\d._-]");
    Java
    - Registered: Sun May 05 03:35:11 GMT 2024
    - Last Modified: Fri Apr 12 10:50:18 GMT 2024
    - 6.2K bytes
    - Viewed (0)
Back to top