A fully functional Notes REST API built with FastAPI and SQLite database.
Data persists after server restarts — no more Python list storage.
- Setting up a SQLite database with SQLAlchemy
- Defining database tables as Python classes (models)
- Separating concerns across multiple files
- Using
Depends()for database session injection - Response models with
NoteOutschema - Full CRUD operations using SQLAlchemy queries
day13-fastapi-sqlite/
│
├── main.py → FastAPI app and all endpoints
├── database.py → Database connection, engine, session
├── models.py → SQLAlchemy table definition
├── schemas.py → Pydantic models for request and response
└── README.md
| Method | Endpoint | Description |
|---|---|---|
| GET | /notes |
Get all notes |
| GET | /notes?keyword=x |
Search notes by keyword in title |
| GET | /notes/important |
Get all important notes |
| GET | /notes/{note_id} |
Get a single note by ID |
| POST | /notes |
Create a new note |
| PUT | /notes/{note_id} |
Update an existing note |
| DELETE | /notes/{note_id} |
Delete a note |
POST /notes
{
"title": "My Note",
"content": "Note content here",
"is_important": false
}PUT /notes/{note_id} — all fields optional
{
"title": "Updated Title",
"is_important": true
}# Clone the repo
git clone https://github.com/studyhaxer/day13-fastapi-sqlite
cd day13-fastapi-sqlite
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Mac/Linux
# Install dependencies
pip install fastapi uvicorn sqlalchemy
# Run the server
uvicorn main:app --reloadOpen http://127.0.0.1:8000/docs to explore and test all endpoints interactively.
- FastAPI — Python web framework
- SQLite — Local file-based database
- SQLAlchemy — ORM for database operations
- Pydantic — Data validation and serialization
- Uvicorn — ASGI server
This is Day 13 of my daily Python learning streak.
Every day — a new concept, a GitHub push, and a LinkedIn post.
Follow the journey: linkedin.com/in/studyhaxer
GitHub: github.com/studyhaxer