Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ on:
pull_request:

jobs:
dialect-sqlite:
uses: ./.github/workflows/dialect-sqlite.yml
secrets: inherit

dialect-postgresql:
uses: ./.github/workflows/dialect-postgresql.yml
secrets: inherit

static-analysis:
name: Static analysis
runs-on: ubuntu-latest
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/dialect-mariadb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "MariaDB dialect tests"

on:
workflow_call:

jobs:
dialect-mariadb-tests:
name: Dialect tests (MariaDB)
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
mariadb_version: ["10.6", "10.11", "11.8", "12.3"]
drivername: ["mariadb+mysqldb", "mariadb+pymysql", "mariadb+mariadbconnector", "mariadb+cymysql"]

services:
mariadb:
image: mariadb:${{ matrix.mariadb_version }}
env:
MARIADB_DATABASE: example
MARIADB_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd "healthcheck.sh --connect --innodb_initialized"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 3

env:
UV_PYTHON: ${{ matrix.python_version }}
DATABASE_URL: ${{ matrix.drivername }}://root:password@localhost:3306/example

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}

- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
enable-cache: true
cache-suffix: mariadb-${{ matrix.python_version }}

- name: Run example project tests
working-directory: example_project
run: uv run --extra mariadb pytest
52 changes: 52 additions & 0 deletions .github/workflows/dialect-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "MySQL dialect tests"

on:
workflow_call:

jobs:
dialect-mysql-tests:
name: Dialect tests (MySQL)
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
mysql_version: ["8.0", "8.4", "9.0"]
drivername: ["mysql+mysqldb", "mysql+pymysql", "mysql+mysqlconnector", "mysql+cymysql"]

services:
mysql:
image: mysql:${{ matrix.mysql_version }}
env:
MYSQL_DATABASE: example
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd "healthcheck.sh --connect --innodb_initialized"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 3

env:
UV_PYTHON: ${{ matrix.python_version }}
DATABASE_URL: ${{ matrix.drivername }}://root:password@localhost:3306/example

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}

- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
enable-cache: true
cache-suffix: mariadb-${{ matrix.python_version }}

- name: Run example project tests
working-directory: example_project
run: uv run --extra mariadb pytest
42 changes: 42 additions & 0 deletions .github/workflows/test-dialects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Test all dialects"

on:
workflow_dispatch:
inputs:
sqlite:
type: boolean
description: "Run SQLite tests"
default: true
postgresql:
type: boolean
description: "Run PostgreSQL tests"
default: true
mariadb:
type: boolean
description: "Run MariaDB tests"
default: true
mysql:
type: boolean
description: "Run MySQL tests"
default: true

jobs:
dialect-sqlite:
if: ${{ inputs.sqlite == 'true' }}
uses: ./.github/workflows/dialect-sqlite.yml
secrets: inherit

dialect-postgresql:
if: ${{ inputs.postgresql == 'true' }}
uses: ./.github/workflows/dialect-postgresql.yml
secrets: inherit

dialect-mariadb:
if: ${{ inputs.mariadb == 'true' }}
uses: ./.github/workflows/dialect-mariadb.yml
secrets: inherit

dialect-mysql:
if: ${{ inputs.mysql == 'true' }}
uses: ./.github/workflows/dialect-mysql.yml
secrets: inherit
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,25 @@ It automatically provisions a dedicated test database per worker and runs Alembi

| Driver | Status |
| ------ | ------ |
| `sqlite+pysqlite` | ✅ Supported
| `sqlite+pysqlcipher` | ✅ Supported
| `postgresql+psycopg` | ✅ Supported
| `postgresql+psycopg2` | ✅ Supported
| `postgresql+pg8000` |
| `postgresql+psycopg2cffi` |
| `postgresql+pg8000` | ✅ Supported
| `postgresql+psycopg2cffi` | ✅ Supported
| `postgresql+asyncpg` | ❌
| `mysql+pymysql` | ❌
| `mariadb+pymysql` | ❌
| `sqlite` | ✅ Supported
| `mariadb+mysqldb` | ✅ Supported
| `mariadb+pymysql` | ✅ Supported
| `mariadb+mariadbconnector` | ✅ Supported
| `mariadb+asyncmy` | ❌
| `mariadb+aiomysql` | ❌
| `mariadb+cymysql` | ✅ Supported
| `mysql+mysqldb` | ✅ Supported
| `mysql+pymysql` | ✅ Supported
| `mysql+mysqlconnector` | ✅ Supported
| `mysql+asyncmy` | ❌
| `mysql+aiomysql` | ❌
| `mysql+cymysql` | ✅ Supported

> [!NOTE]
> If you need an implementation for your particular SQLAlchemy driver, please consider contributing to this project.
Expand Down
21 changes: 18 additions & 3 deletions example_project/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
SHELL := /bin/bash
.DEFAULT_GOAL := help

.PHONY: dev_infra

help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

infra_postgres:
docker compose -p example_project -f docker-compose.yml up -d --build postgres
.PHONY: infra_postgres
infra_postgres: ## Start PostgreSQL container
@docker compose -p example_project -f docker-compose.yml up -d --build postgres

.PHONY: infra_mariadb
infra_mariadb: ## Start MariaDB container
@docker compose -p example_project -f docker-compose.yml up -d --build mariadb

.PHONY: infra_down
infra_down: ## Stop and remove all containers
@docker compose -p example_project -f docker-compose.yml down

.PHONY: infra_down_volume_purge
infra_down_volume_purge: ## Stop and delete all volumes used by the project
@docker compose -p example_project -f docker-compose.yml down --volumes
18 changes: 18 additions & 0 deletions example_project/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,23 @@ services:
timeout: 5s
retries: 5

mariadb:
image: mariadb:12.3
volumes:
- mariadb_data:/var/lib/mysql
ports:
- 127.0.0.1:3306:3306
environment:
- MARIADB_DATABASE=example
- MARIADB_ROOT_PASSWORD=example
restart: on-failure
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
start_period: 10s
interval: 10s
timeout: 5s
retries: 3

volumes:
postgres_data:
mariadb_data:
7 changes: 7 additions & 0 deletions example_project/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ postgres = [
sqlite = [
"sqlcipher3>=0.6.2",
]
mariadb = [
"cymysql>=1.1.1",
"mariadb>=1.1.14",
"mysql-connector-python>=9.7.0",
"mysqlclient>=2.2.8",
"pymysql>=1.2.0",
]

[dependency-groups]
dev = [
Expand Down
Loading
Loading