返回 Skill 列表
extension
分类: 开发与工程无需 API Key

rocket-store

使用Rocket-Store进行本地基于文件的数据持久化的技能。当需要在没有完整数据库服务器的情况下本地存储持久化数据、记忆或JSON记录时使用。非常适合需要简单本地存储机制的代理。

person作者: jakexiaohubgithub

Rocket-Store Skill

This skill allows you to use the Rocket-Store package to store and retrieve data locally as JSON files. It functions as a lightweight, searchable database using the filesystem.

Prerequisites

  • Python installed in the environment.
  • Rocket-Store package installed: pip install Rocket-Store

Usage Guide

Basic Initialization

from Rocketstore import Rocketstore
rs = Rocketstore()

Configuring Data Storage Area

By default, Rocket-Store uses a temporary system directory. You can specify a custom directory:

rs.options(data_storage_area="./my_local_db", data_format=Rocketstore._FORMAT_JSON)

Storing Data (Post)

# rs.post(collection, key, record, flags)
rs.post("users", "user_1", {"name": "Alice", "age": 30}, Rocketstore._FORMAT_JSON)

Retrieving Data (Get)

# Get a specific record
result = rs.get("users", "user_1")

# Get all records in a collection
all_users = rs.get("users")

# Wildcard search
search_results = rs.get("users", "user_*")

Deleting Data

# Delete a specific record
rs.delete("users", "user_1")

# Delete an entire collection
rs.delete("users")

Step-by-Step Workflow

  1. Setup: Ensure the Rocket-Store package is installed.
  2. Options: Set the data_storage_area if you want the data to persist in a specific project folder.
  3. Operations: Use post, get, and delete to manage your local data.
  4. Verification: Check the specified storage directory to see the JSON files created.

Manual Verification

Confirm that data is being saved in the directory specified in data_storage_area. Each collection will be a subdirectory, and each key will be a JSON file.