docs(readme): DB connection examples for PostgreSQL, MySQL, MSSQL (all ORMs)#8
Merged
Merged
Conversation
…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.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.envexamples with the correct URL shapes (postgresql+psycopg/postgresql+asyncpg,mysql+pymysql/mysql+aiomysql,mssql+pyodbc/mssql+aioodbcwith ODBC Driver 18). Notes the auto-conversion of sync→async URLs for Postgres/MySQL/SQLite and the explicitSQLALCHEMY_ASYNC_DATABASE_URLrequirement for MSSQL..env+ a runnablestartup/shutdownsnippet usingTortoise.init,Tortoise.generate_schemas, andTortoise.close_connections, driven by the attributes the adapter exposes (database_url,app_label,models). Calls out that Tortoise has no MSSQL driver..env+ viewset wiring. Calls out that this adapter's URL parser only supportssqlite/postgres/mysql, so MSSQL users should use SQLAlchemy.ORMFactory.create_adapterfor users who don't want to rely on environment variables.Notes
Tortoise.*calls (Tortoise.init,generate_schemas,close_connections) rather than non-existent adapter methods. The lazy auto-init inTortoiseAdapter._ensure_initializedis mentioned in a comment.SQLAlchemyAdaptergraceful fallback when the async DB-API driver is missing (added in 1.2.1) is referenced in the section's intro for context.