0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

FastAPI を uvicorn で動かしているとき、SQLAlchemy のSQLが二重に出てしまう件

Last updated at Posted at 2024-07-30

発行されたSQL文を表示したいとして検索をすると

engine = create_async_engine(db_url, echo=True)

こんなふうに echo オプションをつけるというのが出てくるんですが、どうも標準でSQLAchermyのエンジンはINFOにSQLを吐くようなんですよね。なので、これをオンにしちゃうと

backend-1  | 2024-07-30 00:44:22,335 INFO sqlalchemy.engine.Engine SELECT id 
backend-1  | FROM users
backend-1  | 2024-07-30 00:44:22 - sqlalchemy.engine.Engine - INFO - SELECT id
backend-1  | FROM users

こんなふうに2回表示されてしまいます。上が SQLAchemry が echo=True で出してるもの、下は(ぼくの環境では) uvicorn が出しているものです。

試行錯誤しています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?