Release: 2.0.29 current release | Release Date: March 23, 2024
Release: 2.0.29 current release | Release Date: March 23, 2024
FastAPI with Async SQLAlchemy, SQLModel, and Alembic This tutorial looks at how to work with SQLAlchemy asynchronously with SQLModel and FastAPI. We'll also configure Alembic for handling database migrations. This tutorial assumes you have experience working with FastAPI and Postgres using Docker. Need help getting up to speed with FastAPI, Postgres, and Docker? Start with the following resources:
Flask アプリのテストで、簡単なものなら sqlite のメモリDBを使えば良いですが、複雑なアプリだと本番環境と同じ RDBMS を使って実行したいことが多いです。 その際、テストごとにDBを初期化すると遅いので、コミットせずに毎回ロールバックで対応したいのですが、 Flask.test_client や WebTest などを使って複数のHTTPリクエストを行うテストでは、リクエストをまたいでデータを引き継ぐ必要があります。 これを実現するために、 テスト中は session.commit() を session.flush(), session.expire_all() に置き換える リクエスト終了時、通常は session.remove() し、テスト中は session.expire_all() する テストごとに session.remove() する。 というカスタマイズ
PugSQL is a simple Python interface for using parameterized SQL, in files, with any SQLAlchemy-supported database. import pugsql # Create a module of database functions from a set of sql files on disk. queries = pugsql.module('resources/sql') # Point the module at your database. queries.connect('sqlite:///foo.db') # Invoke parameterized queries, receive dicts! user = queries.find_user(user_id=42)
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く