Skip to main content

ddb_exporter

ddb_exporter は、AWS DynamoDBのテーブル操作およびデータエクスポートを簡単に行うためのコマンドラインツールです。

インストール

ddb_exporter をインストールするには、以下のコマンドを実行してください:

pip install click boto3

次に、スクリプトファイルを実行可能にして、適切なディレクトリに配置します。

使い方

ddb_exporter コマンドは、AWSのDynamoDBサービスにアクセスして操作を行うためのサブコマンドを提供します。以下に各サブコマンドの詳細を示します。

共通オプション

  • --aws-profile (オプション): 使用するAWSプロファイル名。指定がない場合、デフォルトプロファイルまたは環境変数で設定された認証情報が使用されます。

サブコマンド

list-tables

指定したリージョンのDynamoDBテーブルを一覧表示します。

ddb_exporter list-tables --region <region> [--detail]
  • --region (オプション): AWSリージョン。デフォルトは us-east-1 です。
  • --detail (オプション): テーブルのスキーマ情報も含めて表示します。

export-table

指定したDynamoDBテーブルのデータをJSONファイルにエクスポートします。

ddb_exporter export-table --region <region> --table <table_name> [--output <output_file>] [--overwrite] [--partition-key <key>] [--sort-key <key>] [--sort-key-range <start,end>] [--index-name <index_name>] [--index-partition-key <key>] [--index-sort-key <key>]
  • --region (オプション): AWSリージョン。デフォルトは us-east-1 です。
  • --table (必須): エクスポートするDynamoDBテーブル名。
  • --output (オプション): 出力先のJSONファイルパス。指定がない場合は テーブル名_タイムスタンプ.json 形式で生成されます。
  • --overwrite (オプション): 出力ファイルが既に存在する場合に上書きします。
  • --partition-key (オプション): パーティションキーでデータをフィルタリングします。
  • --sort-key (オプション): ソートキーでデータをフィルタリングします。
  • --sort-key-range (オプション): ソートキーの範囲条件でデータをフィルタリングします(フォーマット: start,end)。
  • --index-name (オプション): セカンダリインデックス名。
  • --index-partition-key (オプション): セカンダリインデックスのパーティションキーでデータをフィルタリングします。
  • --index-sort-key (オプション): セカンダリインデックスのソートキーでデータをフィルタリングします。

認証情報の設定

AWSの認証情報は、以下の方法で設定できます:

  1. AWS CLIでプロファイルを設定する。
    aws configure --profile <profile_name>
    
  2. 環境変数を設定する。
    export AWS_ACCESS_KEY_ID=<your_access_key_id>
    export AWS_SECRET_ACCESS_KEY=<your_secret_access_key>
    export AWS_SESSION_TOKEN=<your_session_token>  # 必要な場合
    

エラー処理

認証情報が見つからない場合や認証に失敗した場合、以下のエラーメッセージが表示されます:

AWS credentials not found. Please configure your credentials or specify a profile.

また、DynamoDB操作に失敗した場合、適切なエラーメッセージが表示されます。

ライセンス

このプロジェクトはMITライセンスの下で公開されています。詳細については LICENSE ファイルを参照してください。

Metadata

Release files for ddb-exporter 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ddb-exporter 0.1.0
File Size Uploaded
ddb_exporter-0.1.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ddb-exporter 0.1.0
File Interpreter ABI Platform
ddb_exporter-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.8 kB

Release files / ddb_exporter-0.1.0.tar.gz

Download URL ddb_exporter-0.1.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
63d36dd7ccdf4e97c15da39c101b249335ee7493e5fda9b01495ba8338c928da
BLAKE2b-256 checksum
How to use checksums
00a4ac8b561ea9108e5135edc2e8f4c60877c8d7e760285238852e62b7ff559f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.1 Windows/10

Release files / ddb_exporter-0.1.0-py3-none-any.whl

Download URL ddb_exporter-0.1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21ef94d057cfbb4bcb65b44ed6d9133dc08e292aac57c54f006bdc72ee28472c
BLAKE2b-256 checksum
How to use checksums
6a7fa2fa2bdc27514ea602874763c506454123ffe9403856ad79b5e51d22a090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.1 Windows/10

Release history Release notifications | RSS feed

This release

0.1.0 This release

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