跳转到内容
项目模板·Pro

Python + SQLite 命令行工具

终端里的记账工具:添加和列出支出、按月按类别汇总、导出 CSV。只用标准库(argparse、sqlite3),无需用 pip 安装任何东西,并附带 unittest 测试。需要 Linux 环境中的 Python。

安装它需要 PocketCode Pro。

如果你的 Android 设备上装了 PocketCode,这会在应用里打开此页面。

预览

文件

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 |

此预览已截短。安装后可获得完整内容。

1.0.0 的变更

首个版本。

相关

Flask + SQLite 网页应用Pro项目模板用 Flask 写的阅读清单:服务端渲染页面和普通表单,数据存入 SQLite,另有一个小型 JSON API。测试使用 Flask 的测试客户端。需要 Linux 环境中的 Python 和 pip,会安装 7 个固定版本的包。Python CSV 报表Pro项目模板把销售 CSV 变成终端摘要和带柱状图的 HTML 页面的脚本:按月、类别和产品汇总。只用标准库,附带示例数据和测试。需要 Linux 环境中的 Python。FastAPI 短链接服务Pro项目模板用 Python、FastAPI 和 SQLite 写的短链接服务。生成短代码、跳转并统计点击,附带单页表单和 pytest 测试。需要 Linux 环境中的 Python 3.10 或更新版本及 pip;会安装 14 个固定版本的包。Rust 命令行:行数统计Pro项目模板用 Rust 写的命令行工具,按语言统计文件夹里的代码行、注释行和空行。这是一个没有依赖的 Cargo 项目,带单元测试。需要 Linux 环境中的 Rust 和 Cargo(约 370 MB)。Express + SQLite 任务 APIPro项目模板基于 Express 5 的任务 API,支持筛选、分页并附带测试。数据存入 node:sqlite,无需编译原生模块。需要带 Node.js 22.13 或更新版本的 Linux 环境;npm install 约下载 3.5 MB。Next.js + Tailwind + i18nPro项目模板Next.js 15 项目,带 next-intl 和 Tailwind CSS,在 /en 和 /es 提供一个英语和西班牙语页面。深色模式跟随系统。需要带 Node.js 的 Linux 环境;首次 npm install 约下载 400 MB。