IoC数据SDK - 提供工业物联网数据查询接口
Project description
ENN IoC 数据SDK
提供工业物联网数据查询和管理功能的Python SDK。
功能特性
- 🚀 高性能: 内置数据缓存机制,提供快速数据访问
- 🔒 类型安全: 完全类型化的实体和Repository接口
- 📦 开箱即用: 预定义的实体和Repository类,无需额外配置
- 🔄 实时同步: 支持数据源的实时更新和缓存同步
- 🛠️ 易于扩展: 支持自定义实体和Repository扩展
安装
从源码安装
git clone https://github.com/enn-energy/enn-iot-oc-sdk.git
cd enn-iot-oc-sdk
pip install -e .
快速开始
1. 基本使用
from ioc_data_sdk import (
BiogasProjectInformationRepoImpl,
MechanismCloudAlgorithmRepoImpl,
MechanismTaskPlanningRepoImpl,
initialize
)
# 初始化SDK(可选)
initialize(
auth_token="your_auth_token",
csrf_token="your_csrf_token",
eo_id="your_enterprise_id",
instance_id="your_instance_id"
)
# 创建Repository实例
project_repo = BiogasProjectInformationRepoImpl()
algo_repo = MechanismCloudAlgorithmRepoImpl()
task_repo = MechanismTaskPlanningRepoImpl()
# 查询数据
project = project_repo.find()
algorithms = algo_repo.list()
tasks = task_repo.list()
# 使用数据
if project:
print(f"客户名称: {project.customerName}")
print(f"总投资: {project.totalInvestment}")
print(f"共找到 {len(algorithms)} 个算法")
for algo in algorithms:
print(f"- {algo.algorithmId}: {algo.schemeId}")
🚀 功能特性
- ✅ 自动实体生成: 根据JSON数据自动生成
@dataclass实体类 - ✅ 智能类型推断: 自动推断字段类型(str, int, float, bool, list, dict)
- ✅ 仓库接口生成: 自动生成单行/多行实体的Repository接口
- ✅ 关系映射支持: 支持外键和嵌套对象关系
- ✅ 配置驱动: 基于YAML配置文件定义实体关系
- ✅ 标准兼容: 完全兼容
ioc-data-python-sdk_3.0.1_README.md规范
📁 项目结构
ioc-sdk-generator/
├── README.md # 项目说明
├── requirements.txt # 依赖包
├── config/
│ └── relations.yaml # 实体关系配置
├── data/
│ └── demo/
│ ├── source/ # JSON数据源
│ │ ├── biogas_project_information.json
│ │ ├── mechanism_cloud_algorithm.json
│ │ └── mechanism_task_planning.json
│ └── relations.yaml # 实体关系定义
├── generator/
│ ├── __init__.py
│ ├── entity_generator.py # 实体生成器
│ ├── repository_generator.py # 仓库生成器
│ ├── type_inferencer.py # 类型推断器
│ └── config_parser.py # 配置解析器
├── output/
│ ├── infrastructure/
│ │ ├── model/ # 生成的实体类
│ │ └── repository/ # 生成的仓库类
│ └── __init__.py
└── main.py # 主入口
🛠️ 使用方法
1. 准备数据
将你的JSON数据文件放入data/demo/source/目录,每个文件对应一个实体。
2. 配置关系
在data/demo/relations.yaml中定义实体关系:
entities:
EntityName:
table: table_name
row_type: single|multiple
fields:
fieldName: {type: string, role: pk|fk|embed, to: RelatedEntity}
3. 运行生成器
python main.py --data-dir data/demo --output-dir output
4. 使用生成的接口
from output.infrastructure.model import BiogasProjectInformation, BiogasProjectInformationRepoImpl
# 创建仓库实例
repo = BiogasProjectInformationRepoImpl()
# 查询数据
project = repo.find()
📋 输出说明
生成器将输出:
- 实体类: 符合规范的
@dataclass实体定义 - 仓库接口: 包含
find()、list()、find_by_id()等方法的Repository - 类型映射: 完整的类型提示和字段映射
- 关系支持: 外键和嵌套对象的自动处理
🎯 支持的字段类型
str- 字符串类型int- 整数类型float- 浮点数类型bool- 布尔类型list- 列表类型dict- 字典类型Optional[List[T]]- 可选列表类型(用于嵌套对象)
⚡ 高级特性
- 智能默认值: 根据类型自动设置合理的默认值
- 字段验证: 支持字段类型和格式验证
- 缓存机制: 内置查询缓存优化
- 错误处理: 统一的异常处理机制
🔧 自定义配置
可以通过修改配置文件来自定义:
- 实体名称映射
- 字段类型推断规则
- 关系定义策略
- 输出格式选项
这个生成器让创建IoC数据SDK变得简单高效!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
enn_iot_oc_sdk-1.0.0.tar.gz
(28.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file enn_iot_oc_sdk-1.0.0.tar.gz.
File metadata
- Download URL: enn_iot_oc_sdk-1.0.0.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
217109c8ccef815056051dfd24c14e4d9989379d50f2a9e308ea23f38554bc74
|
|
| MD5 |
f784599c77d3584b8be665a28ec2f790
|
|
| BLAKE2b-256 |
6654245d24c49344786316764b2b0b9c3ec4a0dfc42b724b81c3746e482ed19e
|
File details
Details for the file enn_iot_oc_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: enn_iot_oc_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 41.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e228c0a5432dd5de00ab15e7f9b15c45543f1718b77fd5d719ce34441fe87b7
|
|
| MD5 |
5e2a46ef5dfa45ad2e766440a2b4d78a
|
|
| BLAKE2b-256 |
4306e8d8033c53a47094c42e92c2a46cd23b8a4841a8fb51060c3293decc7a6f
|