File size: 1,437 Bytes
0b85fad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# Pydantic + FastAPI + SQLModel + SQLite
This template provides a minimal setup to get FastAPI working with a sqlite database.
[SQLModel](https://sqlmodel.tiangolo.com/) is used on top of Pydantic and SQLAlchemy to easily define database objects.
## Getting started
### Install dependencies
First, create a new virtual environment for the project:
```bash
uv venv
```
This will create an environment `.venv/` that you can instantiate like this:
```bash
source .venv/bin/activate
```
Once that's done, install the dependencies like this:
```
uv pip install -e ".[dev]"
```
This will install the project in editable mode, meaning your changes will be reflected in the server.
The dev dependencies are also installed for code formatting.
### Run server
Run:
```bash
make dev
```
Backend server should be available on localhost:
```
INFO: Will watch for changes in these directories: ['/home/wauplin/projects/docker-space-fastapi-react/backend']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [355687] using StatReload
INFO: Started server process [355689]
INFO: Waiting for application startup.
INFO: Application startup complete.
```
Hot reload is enabled, meaning backend is reloaded on each file update.
### Code quality
You can run the formatter with:
```bash
make style
```
and then test everything's fine with:
```bash
make quality
``` |