Skip to content

About SQLAlchemy

As the website of SQLAlchemy mentions:

Quote

SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.

How and why do we use SQLAlchemy

SQLAlchemy is used to create a simple and robust ORM for SQL databases. It is wrapped by SQLModel to create models and interact with the database.

Install SQLAlchemy

SQLAlchemy can be installed using pip:

pip install sqlalchemy

Configuration

Since SQLAlchemy is used by SQLModel, the configuration is done through the models and the database connection.

1
2
3
4
5
6
7
from sqlalchemy import create_engine

# Define the database URL
DATABASE_URL = "sqlite:///./test.db"

# Create the database engine
engine = create_engine(DATABASE_URL, echo=True)

Resources and alternatives

These resources and alternatives are related to the current item (in alphabetical order).