Skip to content

jscheah/fastapi-tutorial-mssql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastapi-tutorial-mssql

The FastAPI SQL database tutorial modified to use mssql+pyodbc.

Proof-of-concept that using FastAPI with mssql does not require aioodbc and async def for path operation functions.

How to run:

Create database backend

docker pull mcr.microsoft.com/mssql/server:2017-latest

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Password_123" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest

Download and unzip to database folder https://excelbianalytics.com/wp/wp-content/uploads/2020/09/5m-Sales-Records.zip

Load testing

docker pull grafana/k6

docker run --rm -i grafana/k6 run --vus 1 --duration 1s - <loadtesting/script.js

To launch uvicorn:

uvicorn sql_app.main:app --reload

Then load the fancy interactive docs page at

http://localhost:8000/docs

Details at

https://fastapi.tiangolo.com/tutorial/

and

https://fastapi.tiangolo.com/tutorial/sql-databases/

GitHub discussion:

sqlalchemy/sqlalchemy#6521

Notes:

  • You may need to tweak SQLALCHEMY_DATABASE_URL in database.py to connect to your SQL Server instance.

About

FastAPI SQL database tutorial using mssql+pyodbc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.2%
  • TSQL 5.5%
  • JavaScript 2.3%