r/FastAPI • • Jan 21 '22

Question Microsoft SQL Server

Will Microsoft SQL Server ever be integrated into fastapi?

0 Upvotes

5 comments sorted by

12

u/Vok250 Jan 21 '22

You can use any database with FastAPI. It's just a web framework. You don't have to use the same ORMs shown in the tutorials.

FastAPI works with any database and any style of library to talk to the database.

A common pattern is to use an "ORM": an "object-relational mapping" library.

Direct quote from the docs here: https://fastapi.tiangolo.com/tutorial/sql-databases/

Just use something like this: https://pypi.org/project/pymssql/

1

u/[deleted] Mar 09 '22

Definitely, I use it!

4

u/Enrique-M Jan 21 '22

As u/Vok250 mentioned, you can use pymssql for SQL Server connectivity. Also, you can use PyODBC after installing the appropriate ODBC driver for your SQL Server version and O/S specifics. After that, the main ORM supported in Python for SQL Server is SQLAlchemy.

1

u/Ivana_Twinkle Jan 21 '22

Microsoft hasn't released a odbc driver compatible with Debian 11 yet.

Debian 11 is used in the python docker image and therefore also the fastapi docker image.

It's a pain.

1

u/Enrique-M Jan 21 '22

Ahhh....ok...I gotchya. 👍🏼