Skip to content

docs(readme): DB connection examples for PostgreSQL, MySQL, MSSQL (all ORMs)#8

Merged
svalench merged 1 commit into
masterfrom
docs/db-connection-examples
Apr 25, 2026
Merged

docs(readme): DB connection examples for PostgreSQL, MySQL, MSSQL (all ORMs)#8
svalench merged 1 commit into
masterfrom
docs/db-connection-examples

Conversation

@svalench
Copy link
Copy Markdown
Owner

Summary

Adds a new "Database connection examples" section to the README, covering connection setup for PostgreSQL, MySQL, and Microsoft SQL Server across all three supported ORMs.

Contents

  • Driver matrix mapping each ORM to the pip packages and DBAPI/ODBC drivers required for Postgres / MySQL / MSSQL.
  • SQLAlchemy (sync + async): pip commands, .env examples with the correct URL shapes (postgresql+psycopg / postgresql+asyncpg, mysql+pymysql / mysql+aiomysql, mssql+pyodbc / mssql+aioodbc with ODBC Driver 18). Notes the auto-conversion of sync→async URLs for Postgres/MySQL/SQLite and the explicit SQLALCHEMY_ASYNC_DATABASE_URL requirement for MSSQL.
  • Tortoise ORM: pip + .env + a runnable startup/shutdown snippet using Tortoise.init, Tortoise.generate_schemas, and Tortoise.close_connections, driven by the attributes the adapter exposes (database_url, app_label, models). Calls out that Tortoise has no MSSQL driver.
  • Peewee: pip + .env + viewset wiring. Calls out that this adapter's URL parser only supports sqlite/postgres/mysql, so MSSQL users should use SQLAlchemy.
  • Building the adapter from code (no env vars) via ORMFactory.create_adapter for users who don't want to rely on environment variables.

Notes

  • The Tortoise snippet uses upstream Tortoise.* calls (Tortoise.init, generate_schemas, close_connections) rather than non-existent adapter methods. The lazy auto-init in TortoiseAdapter._ensure_initialized is mentioned in a comment.
  • The SQLAlchemyAdapter graceful fallback when the async DB-API driver is missing (added in 1.2.1) is referenced in the section's intro for context.
  • Documentation only \u2014 no code changes.

…cross ORMs

Adds a 'Database connection examples' section that documents:

- A driver matrix (PostgreSQL / MySQL / MSSQL) for SQLAlchemy
  sync/async, Tortoise, and Peewee, including which packages to pip
  install and which ODBC driver MSSQL needs.
- SQLAlchemy: pip commands and .env URL examples for psycopg/asyncpg
  (Postgres), pymysql/aiomysql (MySQL), pyodbc/aioodbc (MSSQL with
  ODBC Driver 18). Notes that the adapter auto-converts sync URLs to
  async for Postgres/MySQL/SQLite, and that MSSQL needs an explicit
  SQLALCHEMY_ASYNC_DATABASE_URL.
- Tortoise: pip + .env + a runnable startup/shutdown snippet that uses
  Tortoise.init / Tortoise.generate_schemas / close_connections via
  attributes the adapter exposes (database_url, app_label, models).
  Calls out that Tortoise has no MSSQL driver.
- Peewee: pip + .env + viewset wiring. Calls out that this adapter's
  URL parser only supports sqlite/postgres/mysql, no MSSQL.
- A 'Building the adapter from code (no env vars)' snippet using
  ORMFactory.create_adapter for users who avoid environment variables.

Documentation only \u2014 no code changes.
@svalench svalench merged commit 38f30b0 into master Apr 25, 2026
5 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant