Skip to main content

Nutricare data access package

Project description

nutricare-data-packages

Nutricare 的数据访问基础包,封装 MongoDB 仓储与本地存储抽象基类。

安装

pip install nutricare-data-packages

快速使用

from nutricare_data_packages import StorageBase


class ReportStorage(StorageBase):
    @property
    def storage_subdir(self) -> str:
        return "reports"

    def _write_impl(
        self, relative_path: str, data: bytes, **kwargs
    ) -> tuple[bool, dict | None]:
        target, _ = self.resolve_path(relative_path)
        target.parent.mkdir(parents=True, exist_ok=True)
        target.write_bytes(data)
        return True, None

storage = ReportStorage()
relative_path = "daily/report.txt"
content = b"hello"
ok = storage.write(relative_path, content)

说明:

  • MongoDB 连接串只从环境变量 mongodb_url 读取。
  • 允许传入 127.0.0.1:27017mongodb:127.0.0.1:27017 或完整 mongodb://...
  • write 是统一入口:自动做路径校验、md5 计算、元数据写入和幂等判断。
  • NUTRICARE_TICKET_IDNUTRICARE_TASK_ID 从环境变量读取。

本地构建与发布

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
python -m twine upload dist/*

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

nutricare_data_packages-0.1.10.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

nutricare_data_packages-0.1.10-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file nutricare_data_packages-0.1.10.tar.gz.

File metadata

  • Download URL: nutricare_data_packages-0.1.10.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for nutricare_data_packages-0.1.10.tar.gz
Algorithm Hash digest
SHA256 77f4d82473db5863d628d33d90b5682ef7e501e93c52ff80d477c1b2e812618f
MD5 2e1cfc640adb565b9720f634aa8d0852
BLAKE2b-256 da762f977b0c200d30c2a5a7179b37c988a36e0301fc36544d437ef7af2eb704

See more details on using hashes here.

File details

Details for the file nutricare_data_packages-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for nutricare_data_packages-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 f66b799d31b52df8c259debc996a7dcc7e42945e66184907a47953fac23adef1
MD5 b1b854041ac74e4a02ceb6107d74fd7f
BLAKE2b-256 08be180e0e856fd0e3b28a2bb6dd402b62b47455199db81095b11d5458a1b6e3

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