Skip to main content

enebular-sdk

enebularのクラウド実行環境上で動作するアプリケーションを開発するためのSDKです。 本SDKを利用することにより、enebularのデータストアを利用するアプリケーションを開発できます。

対応環境

  • 実行環境: enebularのクラウド実行環境
  • ランタイム: Python 3.13

インストール

pip install enebular-sdk

クイックスタート

from enebular_sdk import CloudDataStoreClient
import time
import json

datastore = CloudDataStoreClient()

def handler(event, context):
    # データの保存
    datastore.put_item({
        'table_id': 'bec32e12-655b-480b-88a8-6ba7d515aea5',
        'item': {
            'deviceId': 'device-001',
            'timestamp': int(time.time() * 1000),
            'temperature': 25.5
        }
    })

    result = datastore.query({
        'table_id': 'bec32e12-655b-480b-88a8-6ba7d515aea5',
        'expression': '#deviceId = :deviceId',
        'values': {'deviceId': 'device-001'},
        'order': False,  # False = descending
        'limit': 10
    })

    return {
        'statusCode': 200,
        'body': json.dumps(result.get('params', {}).get('Items'))
    }

操作対象のテーブルはテーブルIDで指定します。テーブルIDは以下の手順で取得できます。

  1. enebularにログインする
  2. 左側のメニューからデータストアを選択する
  3. アクセスしたいテーブルを選択する
  4. 設定タブを開く
  5. テーブルIDが表示されるので右側のコピーアイコンをクリックしコピーする

機能

データストア

enebularのデータストアのテーブルに対してデータの読み書き削除等の操作を行います。 主な操作の種類は以下の通りです。

  • CloudDataStoreClient - データストア操作のインスタンス作成
  • get_item - データの取得
  • put_item - データの保存
  • delete_item - データの削除
  • query - データのクエリ

あらかじめenebularで、操作対象のテーブルを作成しておく必要があります。

以下に使い方を示します。

データストア操作のインスタンス作成

from enebular_sdk import CloudDataStoreClient

datastore = CloudDataStoreClient()

以降の使用例ではこのdatastoreインスタンスを利用して、データストアの操作を行います。

データの取得

result = datastore.get_item({
    'table_id': 'bec32e12-655b-480b-88a8-6ba7d515aea5',
    'key': {'deviceId': 'device-001', 'timestamp': 1234567890}
})

if result['result'] == 'success':
    print(result.get('params', {}).get('Item'))

get_itemの戻り値の形式:

{
    "result": "success" | "fail",  # 成功(success)/失敗(fail)を表します
    "error": str,                  # 失敗の場合、エラーメッセージを保持します
    "params": {"Item": any}        # 成功した場合、Itemに取得したデータを保持します
}

データの保存

datastore.put_item({
    'table_id': 'bec32e12-655b-480b-88a8-6ba7d515aea5',
    'item': {
        'deviceId': 'device-001',
        'timestamp': int(time.time() * 1000),
        'temperature': 25.5,
        'humidity': 60
    }
})

put_itemの戻り値の形式:

{
    "result": "success" | "fail",  # 成功(success)/失敗(fail)を表します
    "params": {"Item": any},       # 成功した場合、Itemに登録したデータを保持します
    "error": str                   # 失敗の場合、エラーメッセージを保持します
}

データの削除

datastore.delete_item({
    'table_id': 'bec32e12-655b-480b-88a8-6ba7d515aea5',
    'key': {'deviceId': 'device-001', 'timestamp': 1234567890}
})

delete_itemの戻り値の形式:

{
    "result": "success" | "fail",  # 成功(success)/失敗(fail)を表します
    "error": str,                  # 失敗の場合、エラーメッセージを保持します
    "params": {"Item": any}        # 成功した場合、Itemに削除したデータを保持します
}

データの検索

import time

result = datastore.query({
    'table_id': 'bec32e12-655b-480b-88a8-6ba7d515aea5',
    'expression': '#deviceId = :deviceId and #timestamp > :timestamp',
    'values': {
        'deviceId': 'device-001',
        'timestamp': int(time.time() * 1000) - 86400000  # 過去24時間
    },
    'order': True,  # True=昇順, False=降順
    'limit': 100  # limitを設定しない場合は10とする
})

queryの戻り値の形式:

{
    "result": "success" | "fail",  # 成功(success)/失敗(fail)を表します
    "error": str,                  # 失敗の場合、エラーメッセージを保持します
    "params": {
        "Items": [any],            # 成功した場合、Itemに取得したデータを保持します
        "LastEvaluatedKey": str,   # 今回取得したデータの続きのデータを取得するキーを保持します*1
        "Count": int               # 取得したデータ数を保持します
    }
}

*1: LastEvaluatedKeyの値をquery実行時のパラメーターにstart_keyとして追加することで続きを取得できます

ロガー

ログを出力します。 出力したログは、enebularのクラウド実行環境画面で閲覧できます。

以下に使い方を示します。

from enebular_sdk import Logger

logger = Logger("MyContext")

logger.error("エラーメッセージ", error)
logger.warn("警告メッセージ", data)
logger.info("情報メッセージ", data)
logger.debug("デバッグメッセージ", data)

ログの出力例:

[Dec 19th 2025, 13:00:50]:  2025-12-19T04:00:50.491Z	adfff29c-658d-4c44-9530-9a33298950b6	ERROR	2025-12-19T04:00:50.491Z [enebular-sdk] [ERROR] [MyContext] エラーメッセージ

出力対象のログは環境変数 LOG_LEVEL で設定できます。

  • ERROR: error関数のログのみ出力します
  • WARN: error、warn関数のログを出力します
  • INFO: error、warn、info関数のログを出力します
  • DEBUG: error、warn、info、debug関数のログを出力します
  • TRACE: error、warn、info、debug、trace関数のログを出力します

環境変数は、enebularのクラウド実行環境画面で設定できます。

型ヒントサポート

このSDKは型ヒントを提供しています。IDEでの自動補完やタイプチェックが利用できます。

enebularへのデプロイ

作成したプログラムをenebularのクラウド実行環境にデプロイして実行します。 デプロイする方法については、enebularのチュートリアルをご参照ください。

ライセンス

MIT

Metadata

Release files for enebular-sdk 1.0.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 enebular-sdk 1.0.1
File Size Uploaded
enebular_sdk-1.0.1.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for enebular-sdk 1.0.1
File Interpreter ABI Platform
enebular_sdk-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / enebular_sdk-1.0.1.tar.gz

Download URL enebular_sdk-1.0.1.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0b867e08a5a440952b4d3766b4d9b5f17c81ee5a5393d8a7f7d67a7bbbd1e206
BLAKE2b-256 checksum
How to use checksums
ae16756f7b81838aaeb78d01003d34dc898fb8b53678f09e3f42e52175de52cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 29, 2026.

Transparency log

Release files / enebular_sdk-1.0.1-py3-none-any.whl

Download URL enebular_sdk-1.0.1-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
773fc1cd3c19f386bde8eb505ee17b0ac3f675460190a6fb3ee8c9b2904b87b8
BLAKE2b-256 checksum
How to use checksums
92e49388d71b59fc42124b46a66e37da08cb93dc555ec3b501b90df415ed425e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

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