Skip to main content

cndb

通用数据库管理平台。

PyPI CI Python License Coverage

特性

  • 技术栈:Django 5.2 + DRF + PostgreSQL(开发/测试可用 SQLite)
  • 元数据驱动:数据表/字段定义存元数据库,字段类型系统插件式扩展(9 种内置类型)
  • 动态 DDL:物理表/列名系统生成,用户输入永不进入 SQL 标识符
  • 视图规则:Grid/Kanban/Calendar/Gallery/Form 五种形态,筛选/排序/字段选项保存期校验,聚合统计(count/sum/avg/min/max)
  • 权限体系:工作区五级角色 → 表级动作制 → 行级范围 → 字段级隐藏;API Token 认证
  • 表单与共享:表单视图匿名提交;grid 视图公开共享(slug 匿名只读)
  • 导入导出:CSV/JSON 双向流转,错误行按原始行号报告
  • 前端:Django 模板 + 原生 JS 无构建(登录/工作区/表/Grid)

快速上手

# 安装依赖并启动开发服务器(自动迁移,http://127.0.0.1:8000)
uv sync --extra dev
make dev

# 写入演示数据(示例用户/工作区/任务表/看板/日历/公开表单/共享视图,幂等)
make seed

演示账号:demo-owner / demo-editor,密码均为 Demo-Pass-42。

常用命令(make help 查看全部):

命令 说明
make dev 启动开发服务器(自动迁移)
make seed 写入演示数据(幂等)
make su 创建超级用户(需 DJANGO_SUPERUSER_PASSWORD 环境变量)
make routes 列出全部 URL 路由
make up / make down 启停生产容器(gunicorn + PostgreSQL)
make check 全套门禁(lint + typecheck + cov ≥95%)

REST API 入口:/api/auth/、/api/workspaces/、/api/tokens/、/api/forms/、/api/views/,管理后台:/admin/。

切换 PostgreSQL:设置 CNDB_DB=postgres 及 CNDB_DB_NAME/CNDB_DB_USER/CNDB_DB_PASSWORD 等环境变量。

部署

生产部署使用 Docker Compose(gunicorn + PostgreSQL 17):

cd deploy
# 在 .env 中设置 CNDB_SECRET_KEY 与 CNDB_DB_PASSWORD(必填)
echo "CNDB_SECRET_KEY=<随机密钥>" > .env
echo "CNDB_DB_PASSWORD=<数据库密码>" >> .env
docker compose up -d
docker compose exec web python manage.py migrate   # 首次启动执行迁移

访问 http://localhost:8000/。CNDB_ALLOWED_HOSTS 环境变量控制允许的Host 头(默认 localhost,127.0.0.1)。

性能基准

行数据服务层吞吐基准(make check 之外单独运行):

uv run pytest tests/test_bench_rows.py -m slow -s --no-cov

开发

# 安装开发依赖
uv sync --extra dev

# 运行测试(含覆盖率,阈值 95%)
uv run pytest -m "not slow" --cov=cndb --cov-fail-under=95

# 类型检查
uv run pyrefly check .

# 代码风格
uv run ruff check src tests
uv run ruff format --check src tests

Make 快捷命令

项目提供 Makefile 封装常用操作,运行 make help 查看全部命令:

make sync     # 安装开发依赖
make check    # 全套门禁 (lint + typecheck + cov)
make build    # 构建分发包
make clean    # 清理构建产物
make bump PART=patch  # 版本号 bump

文档

文档由 Sphinx 构建,托管在 ReadTheDocs:

# 本地构建文档
make doc

多版本测试

使用 tox 在多个 Python 版本(py311, py312, py313, py314)下运行测试:

make tox

许可证

MIT

Metadata

Release files for cndb 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cndb 0.1.1
File Size Uploaded
cndb-0.1.1.tar.gz 178.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cndb 0.1.1
File Interpreter ABI Platform
cndb-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 289.4 kB

Release files / cndb-0.1.1.tar.gz

Download URL cndb-0.1.1.tar.gz
Size 178.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7652f7d338c12043b1d878dd3c533735f9c3762ee7f9ed73d50c93c0e77f3209
BLAKE2b-256 checksum
How to use checksums
19330a2dfa0ea029f0c3c528a1d1fc84339a0587b6b9d67bea660988efbb9601
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cndb-0.1.1-py3-none-any.whl

Download URL cndb-0.1.1-py3-none-any.whl
Size 111.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e51ae1bafa73d336c1aca5fdeead1e2233680e410f194b42c65f5d56bb14b23
BLAKE2b-256 checksum
How to use checksums
1d87faf099d16b8cd80baaf869cf5967416b6a34371482442d6653dd9179a911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.4.1

2 release files

0.4.0

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.14

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.6

2 release files

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page