Setting up SQLAlchemy
To begin any data application, you need to establish a database connection. This recipe will help you set up and configure sqlalchemy
package with an SQLite database so that you can use the advantages of SQL databases in your applications.
Getting ready
The project is going to be fairly large, so we will put the working modules for the application in a folder named app
, which will be under the root project folder that we will call ticketing_system
.
You need fastapi
, sqlalchemy
, and aiosqlite
installed in your environment to use the recipe. The recipe is meant to work with sqlalchemy
with versions above 2.0.0. You can still use version 1; however, some adaptions are required. You can find a migration guide at the following link: https://docs.sqlalchemy.org/en/20/changelog/migration_20.html.
If you haven’t installed the packages with the requirements.txt
file in the repo, you can do it by running the following:
$ pip install fastapi[all] "...