← All libraries

SQLAlchemy

Python
↗ Official site

Database & backend

Python's most popular database toolkit — connect to any SQL database.

What it does

SQLAlchemy is the standard way to connect Python apps to databases. It supports PostgreSQL, MySQL, SQLite, and more. You can use it as a raw SQL executor or as a full ORM.

When to use it

Use this when building a Python backend or data pipeline that needs to store or query data in a SQL database.

Real example

You're building a FastAPI backend for a doctor's appointment app and need to query patients from a PostgreSQL database. Prompt: 'Use SQLAlchemy with the async engine. Define a Patient model with id, name, dob, and doctor_id. Create a get_patients() function that queries all patients for a given doctor_id and returns them as a list.'

Good to know

The foundation of most Python web apps and data pipelines. FastAPI and Flask both work great with it.

Alternatives

Peewee Tortoise ORM

Install

$ pip install sqlalchemy

Use cases

databaseORMPythonbackendSQL

Language

Python

Category

Database & backend

More in Database & backend

Other tools in the same category