Skip to main content

High-performance embedded database with Rust core and Python API

Project description

ApexBase

High-performance embedded database with Rust core and Python API

ApexBase 是一个基于 Rust 核心的高性能嵌入式数据库,提供简洁的 Python API。

✨ 特性

  • 🚀 高性能 - Rust 核心,批量写入速度可达 97万+ ops/s
  • 📦 单文件存储 - 自定义 .apex 文件格式,无需外部依赖
  • 🔍 全文搜索 - 集成 NanoFTS,支持中文和模糊搜索
  • 🐍 Python 友好 - 简洁的 API,支持 Pandas/Polars/PyArrow
  • 💾 紧凑存储 - 相比传统方案节省约 45% 存储空间

📦 安装

# 从 PyPI 安装
pip install apexbase

# 从源码构建(推荐在 conda dev 环境中)
# conda activate dev
maturin develop --release

🚀 快速开始

from apexbase import ApexClient

# 创建客户端
client = ApexClient("./data")

# 存储数据
client.store({"name": "Alice", "age": 30, "city": "Beijing"})
client.store([
    {"name": "Bob", "age": 25},
    {"name": "Charlie", "age": 35}
])

# SQL 查询(推荐)
results = client.execute("SELECT * FROM default WHERE age > 28")

# 也支持传入过滤表达式(兼容用法)
results2 = client.query("age > 28", limit=100)

# 按 _id 检索(_id 为内部自增 ID)
record = client.retrieve(0)
all_data = client.retrieve_all()

# 全文搜索
client.init_fts(index_fields=["name", "city"], lazy_load=True)
doc_ids = client.search_text("Alice")
records = client.search_and_retrieve("Beijing")

# 转换为 DataFrame
df = results.to_pandas()
pl_df = results.to_polars()

# 关闭连接
client.close()

📊 性能对比

操作 ApexBase (Rust) 传统方案 提升
批量写入 (10K) 17ms 57ms 3.3x
单条检索 0.01ms 0.4ms 40x
批量检索 (100) 0.08ms 1.1ms 14x
存储大小 2.1 MB 3.9 MB 1.8x 更小

📁 项目结构

ApexBase/
├── apexbase/                    # 主包目录
│   ├── src/                     # Rust 源代码
│   │   ├── storage/             # 存储引擎
│   │   ├── table/               # 表管理
│   │   ├── query/               # 查询执行器
│   │   ├── index/               # B-tree 索引
│   │   ├── cache/               # LRU 缓存
│   │   ├── data/                # 数据类型
│   │   └── python/              # PyO3 绑定
│   ├── python/                  # Python 包装层
│   │   └── apexbase/
│   │       └── __init__.py      # Python API
│   ├── Cargo.toml
│   └── pyproject.toml
├── Cargo.toml                   # 工作区配置
└── pyproject.toml               # 项目配置

🔧 API 参考

ApexClient

# 初始化
client = ApexClient(
    dirpath="./data",           # 数据目录
    drop_if_exists=False,       # 是否删除已存在的数据
    batch_size=1000,
    enable_cache=True,
    cache_size=10000,
    prefer_arrow_format=True,
    durability="fast",         # fast | safe | max
)

# 表操作
client.create_table("users")
client.use_table("users")
client.drop_table("users")
tables = client.list_tables()

# CRUD 操作
client.store({"key": "value"})
client.store([{...}, {...}])
record = client.retrieve(0)
records = client.retrieve_many([1, 2, 3])
client.replace(0, {"new": "data"})
client.delete(0)
client.delete([1, 2, 3])

# 查询
results = client.query("age > 30")
results = client.query("name LIKE 'A%'")
results = client.execute("SELECT name, age FROM default ORDER BY age DESC LIMIT 10")
count = client.count_rows()

# 全文搜索
client.init_fts(index_fields=["title", "content"], lazy_load=True)
ids = client.search_text("keyword")
ids = client.fuzzy_search_text("keywrd")  # 模糊搜索
records = client.search_and_retrieve("keyword")

# 数据框架集成
client.from_pandas(df)
client.from_polars(df)
results.to_pandas()
results.to_polars()
results.to_arrow()

🧪 开发与测试

# 运行测试(conda dev 环境推荐)
# conda activate dev
python run_tests.py

# 或直接 pytest
pytest -q

📦 发布流程(GitHub Actions)

当前仓库已提供基于 tag 的自动构建与发布流程:当推送 v* tag 时,会运行测试、构建 wheels/sdist 并使用 twine 发布到 PyPI。

  • Workflow: .github/workflows/build_release.yml
  • Tag: v0.2.3 这类格式
  • Secret: PYPI_API_TOKEN

📚 文档

项目文档入口:docs/README.md

📄 License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apexbase-0.2.3.tar.gz (270.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

apexbase-0.2.3-cp313-cp313-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.13Windows x86-64

apexbase-0.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

apexbase-0.2.3-cp313-cp313-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

apexbase-0.2.3-cp312-cp312-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.12Windows x86-64

apexbase-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

apexbase-0.2.3-cp312-cp312-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

apexbase-0.2.3-cp311-cp311-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.11Windows x86-64

apexbase-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

apexbase-0.2.3-cp311-cp311-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

apexbase-0.2.3-cp310-cp310-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.10Windows x86-64

apexbase-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

apexbase-0.2.3-cp310-cp310-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

apexbase-0.2.3-cp39-cp39-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.9Windows x86-64

apexbase-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

apexbase-0.2.3-cp39-cp39-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file apexbase-0.2.3.tar.gz.

File metadata

  • Download URL: apexbase-0.2.3.tar.gz
  • Upload date:
  • Size: 270.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for apexbase-0.2.3.tar.gz
Algorithm Hash digest
SHA256 8f26230304504cf2160229b120cdee5644634efb5a4d953c818c06dbd12ea373
MD5 184a807045faf1cb0eba71bddd1853e0
BLAKE2b-256 718a36607270ef461a98b6172490812347825f5f71c00ce4510691bde54218c2

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: apexbase-0.2.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for apexbase-0.2.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e170ab5537bb542ad1603dd0c3652ce2d8f923c1dee5e9877ab7d300cb1bd93e
MD5 e5a5193aaa67345452edb350c06b0693
BLAKE2b-256 93eb8b251d306cacdd4f54bcb5cf6b18e5b26946500ff7f8947050893f451869

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 986a4c74afdd52bdccfee0b9b29c32ff27434364b8216caf611e8f8670e8a219
MD5 ae7f2e2ddd9db828fadab69eb9d73ec9
BLAKE2b-256 6f2769c6a870b107df8261e207fc408397d49b937ceb8c183dc335b081fff55a

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08d9dfdffec520247c020e57d31e1a12929db7ebff2f10dae4cc5804b21b52e0
MD5 8d247698138bc7ad2575d4d1e4d10877
BLAKE2b-256 8253defb1224542f7b5ead8a41e3edccc5f546ecd3d8f7043f8940736651dc60

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: apexbase-0.2.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for apexbase-0.2.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bf794fed2164673a2ef7c210b78dec11fe4df04bd6eaada13097384f4e99701e
MD5 49060aa46ec0e1cb83b6ee8d2bb9fd76
BLAKE2b-256 4467a7abd507740fbc2436abe9a94830db1cf992861fe25fa2c1924321a66151

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e6506abaa671a8af05587505720b92b28bea0acfd111fa60d80b1ad58d7368e
MD5 041a62add509ff372d981b084f5f6012
BLAKE2b-256 0b7caaec6cb6c29f76dea620419bc8065f365da30c1e94ed59ecca57c7e1cc1a

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63504e722734e1ad170bfce0358b38e27c291c95c2c41d0704d4eed8541fedf9
MD5 1fd45b9d594886bd6dbed7e65acc04fc
BLAKE2b-256 c1303d6f2951434fb12e4744984baa47c8388e3bd66fb2c1cb10d27ff28b3293

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: apexbase-0.2.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for apexbase-0.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cb1bb0c9fc8d5bbae4064dee0fc23e8da3f318f1d8fcd2f47960e975c010c6c4
MD5 6b7f3975f6abf98ba76d7e5609598dad
BLAKE2b-256 7610872740c85833ae508ff82203552ea8d252dac1ba41f9ce60b96f07a7dab1

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09a79cedef3197e8f32e035db3b8566e4a5c5fb8e3eb4dd66e914df18cb1d3bb
MD5 d49930ab55b2e7a13fd507fd7f4ae029
BLAKE2b-256 2bec41fab2c35c30d64e2889c8bf7d448003479bb80ea814d9bdc8e4c3262257

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d150853c2f152b6256aa243f5a7514f9db5af92241d1f0599c41f68494223873
MD5 9b2a9f283b331e6defefcb44ac4f707d
BLAKE2b-256 d66572b8d7f25e97d93cd8a4e7032153bb2092f41a46df2deec42061099995a4

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: apexbase-0.2.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for apexbase-0.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 86d5bb65083ef3518517973bf2a97ef12fd9527ba4ebcc1b522ea14488ac49bf
MD5 66e73b1cac970f8de68e96c8dd98eb64
BLAKE2b-256 6121fd215676273c9c24bcd9675f7aa84e27246007533bcd735a52a390170c8b

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d5b5364646067422a0dfa21de454f7b1dccabd96da918d3aee51a4eb34063d74
MD5 540441f9a36c6541a3658992eb14bf28
BLAKE2b-256 0b4352298fdfce0fcbe63671a776d29e15d298d7280ade9c7febc49b316a6b58

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b75d5383c1295760f99a873b31bd61589dd32df4494ebab9e281076b97890f6
MD5 e19375df054bfea6ea58406820d97fb6
BLAKE2b-256 80a979562180e326015a0979932f210c0e8161ca758a20288e50511caae00d24

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: apexbase-0.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for apexbase-0.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1bf9c994c20e6fb9872b763adc3ae2a6095d512e9bce546915003d0fa109c2c5
MD5 82e64984fa0efd89dbb5ab8ff6e532d9
BLAKE2b-256 bbc2223aab48895cceafb9bf1f9ccb11b96ade32988cadb01b7f44fc74052fc2

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a05d1b6b3ac7ece444aca0b3206d827fbd7602e6e4fdd1834f3e956d113cbd9
MD5 2eb90e058532520c11b0966b325fd5cf
BLAKE2b-256 792af12f2537da7b4ec8ff1ac22e74093ff54d258784ea3233d3daeada80d45e

See more details on using hashes here.

File details

Details for the file apexbase-0.2.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for apexbase-0.2.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 47f0ec82fab2ff32829c86ba6a424d3c1bda3aeaff312908052b7607071e1cc5
MD5 57db87c322d0da1b37b7457fb44f8a7d
BLAKE2b-256 4bc914582226a9a7dd15acf2d7f894fdd8ff7dffe8b5de776f49e5e89bbdfd67

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page