You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.6 KiB

🔬 💽

👆 💪 ⚙️ 🎏 🔗 🔐 ➡️ 🔬 🔗 ⏮️ 🔐{.internal-link target=_blank} 📉 💽 🔬.

👆 💪 💚🆙 🎏 💽 🔬, 💾 💽 ⏮️ 💯, 🏤-🥧 ⏮️ 🔬 💽, ️.

👑 💭 🎏 👆 👀 👈 ⏮️ 📃.

🚮 💯 🗄 📱

➡️ ℹ 🖼 ➡️ 🗄 (🔗) 💽{.internal-link target=_blank} ⚙️ 🔬 💽.

🌐 📱 📟 🎏, 👆 💪 🚶 🔙 👈 📃 ️.

🕴 🔀 📥 🆕 🔬 📁.

👆 😐 🔗 get_db() 🔜 📨 💽 🎉.

💯, 👆 💪 ⚙️ 🔗 🔐 📨 👆 🛃 💽 🎉 ↩️ 1️⃣ 👈 🔜 ⚙️ 🛎.

👉 🖼 👥 🔜🍕 💽 🕴 💯.

📁 📊

👥🆕 📁 sql_app/tests/test_sql_app.py.

🆕 📁 📊 👀 💖:

.
└── sql_app
    ├── __init__.py
    ├── crud.py
    ├── database.py
    ├── main.py
    ├── models.py
    ├── schemas.py
    └── tests
        ├── __init__.py
        └── test_sql_app.py

🆕 💽 🎉

🥇, 👥🆕 💽 🎉 ⏮️ 🆕 💽.

💯 👥 🔜 ⚙️ 📁 test.db ↩️ sql_app.db.

🎂 🎉 📟 🌅 ⚖️ 🌘 🎏, 👥 📁 ️.

{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}

!!! tip 👆 💪 📉 👈 📟 🚮 🔢 & ⚙️ ➡️ 👯‍♂️ database.py & tests/test_sql_app.py.

🦁 & 🎯 🔛 🎯 🔬 📟, 👥 🖨 ⚫️.

💽

↩️ 🔜 👥 🔜 ⚙️ 🆕 💽 🆕 📁, 👥 💪💭 👥💽 ⏮️:

Base.metadata.create_all(bind=engine)

👈 🛎 🤙 main.py, ️ ⏸ main.py ⚙️ 💽 📁 sql_app.db, & 👥 💪💭 👥test.db 💯.

👥 🚮 👈📥, ⏮️ 🆕 📁.

{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}

🔗 🔐

🔜 👥🔗 🔐 & 🚮 🔐 👆 📱.

{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}

!!! tip 📟 override_get_db() 🌖 🎏 get_db(), override_get_db() 👥 ⚙️ TestingSessionLocal 🔬 💽 ↩️.

💯 📱

⤴️ 👥 💪 💯 📱 🛎.

{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}

& 🌐 🛠️ 👥💽 ⏮️ 💯 🔜 test.db 💽 ↩️ 👑 sql_app.db.