Will It Vibe logoWill It Vibe?
FASTAPI-005Medium severity-8 points

Synchronous database driver call inside an async route handler

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.

What it detects

psycopg2, pymysql, sqlite3, MySQLdb, and cx_Oracle are synchronous drivers: connect() blocks on network or disk I/O. Calling one directly inside an async def handler blocks the event loop for every other request.

Why it matters

psycopg2, pymysql, sqlite3, MySQLdb, and cx_Oracle are all synchronous drivers: connect() blocks on network or disk I/O to establish the connection. Called directly inside an async def handler, that blocks the event loop for every other request for as long as the connection takes to open, and the same is true of every synchronous query made through that connection afterward.

How to fix it

Switch to the async counterpart for your database: asyncpg or the async engine of SQLAlchemy for Postgres, aiomysql for MySQL, aiosqlite for SQLite. If migrating the driver is not immediately practical, run the synchronous connect/query calls through await run_in_threadpool(...) so they at least run off the event loop thread.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks