Skip to content
Project template·Pro

Python CLI with SQLite

An expense tracker for the terminal. It adds and lists expenses, totals them per category each month and exports CSV. It only uses the standard library (argparse, sqlite3), so there's nothing to pip install, and it has unittest tests. It needs Python in the Linux environment.

You need PocketCode Pro to install it.

If PocketCode is installed on your Android device, this opens the page in the app.

Preview

Files

README.md
expenses/__init__.py
expenses/__main__.py
expenses/cli.py
expenses/db.py
main.py
tests/__init__.py
tests/test_cli.py

README.md

# Expense tracker: Python CLI with SQLite A command-line tool to log what you spend and see totals per category for each month. It only uses Python's standard library (argparse, sqlite3, csv, decimal), so there is nothing to install with pip. Data goes to `expenses.db` in the project folder. Comes with tests. ## Run it in PocketCode You need the app's Linux environment with Python 3.10 or newer: install it in Settings › Compilers and runtimes, or with the Developer pack in Terminal › Linux. When you tap Run, the first line of the Run panel should say Python 3 (Linux). - **Run button**: open `main.py` and tap Run. With no arguments it prints this month's summary. - **Terminal**: open it in this project's folder (Open Terminal Here, in the editor menu) and pass commands: ```sh python3 main.py add 12.50 food "Lunch" python3 main.py add 30 transport --day 2026-12-01 python3 main.py list --month 2026-12 python3 main.py summary python3 main.py export december.csv --month 2026-12 python3 main.py delete 2 ``` `python3 -m expenses …` does the same as `python3 main.py …`. Add `-h` to any command for its help. ## Run the tests ```sh python3 -m unittest -v ``` The tests use a temporary database, so they never touch `expenses.db`. ## Where things are | Path | What it does | |---|---| | `main.py` | Entry point for the Run button | | `expenses/cli.py` | The commands and their options (argparse) | | `expenses/db.py` | The SQLite table, amounts in cents, totals |

This preview is shortened. You get the full content when you install it.

Changes in 1.0.0

First version.

Related

Flask + SQLite web appProProject templateA reading list in Flask with server-rendered pages and plain forms, SQLite storage and a small JSON API. The tests use Flask's test client. It needs Python and pip in the Linux environment and installs 7 pinned packages.Python CSV reportProProject templateA script that turns a CSV of sales into a summary in the terminal and an HTML page with bar charts of totals per month, category and product. It only uses the standard library and includes sample data and tests. It needs Python in the Linux environment.FastAPI link shortenerProProject templateA link shortener in Python with FastAPI and SQLite: it creates short codes, redirects and counts clicks. It comes with a one-page form and pytest tests. It needs Python 3.10 or newer with pip in the Linux environment and installs 14 pinned packages.Rust CLI: line counterProProject templateA command-line tool in Rust that counts code, comment and blank lines per language in a folder. It's a Cargo project with no dependencies and has unit tests. It needs Rust and Cargo in the Linux environment (about 370 MB).Express + SQLite tasks APIProProject templateA tasks API on Express 5 with filtering, paging and tests. Data goes to node:sqlite, so nothing native has to compile. It needs the Linux environment with Node.js 22.13 or newer, and npm install fetches about 3.5 MB.Next.js + Tailwind + i18nProProject templateNext.js 15 project with next-intl and Tailwind CSS, and one page in English and Spanish at /en and /es. Dark mode follows the system. Needs the Linux environment with Node.js; the first npm install downloads around 400 MB.