### Install and Initialize Pre-commit Hooks Source: https://github.com/awslabs/dynein/blob/main/CONTRIBUTING.md Installs the pre-commit tool (using Homebrew as an example) and initializes pre-commit hooks for automated linting and checks before committing code. ```shell brew install pre-commit # (or appropriate for your platform: https://pre-commit.com/) pre-commit install ``` -------------------------------- ### DynamoDB Local Setup and Commands with Dynein Source: https://context7.com/awslabs/dynein/llms.txt Instructions for setting up and interacting with DynamoDB Local using Dynein. This includes starting DynamoDB Local via Docker or Kubernetes, and then using Dynein commands with the '--region local' flag to manage tables, data, and perform scans. ```bash # Start DynamoDB Local with Docker docker run -p 8000:8000 -d amazon/dynamodb-local # Or with Kubernetes kubectl apply -f k8s-deploy-dynamodb-local.yml kubectl port-forward deployment/dynamodb 8000:8000 # Use --region local for all commands dynein --region local admin create table test --keys id,S dynein --region local use test dynein --region local put "item1" --item '{"name": "Test Item"}' dynein --region local scan dynein --region local get "item1" # Configure port if DynamoDB Local runs on different port dynein --region local --port 8001 list # All commands work the same with --region local: dynein --region local query "key1" dynein --region local upd "item1" --set "count = count + 1" dynein --region local export --output-file backup.json --format json ``` -------------------------------- ### Install Rustfmt and Clippy Components Source: https://github.com/awslabs/dynein/blob/main/CONTRIBUTING.md Installs the rustfmt and clippy components for Rust development, which are recommended for maintaining code quality and enforced by GitHub Actions. ```shell rustup component add rustfmt clippy ``` -------------------------------- ### Install dynein CLI using Homebrew Source: https://github.com/awslabs/dynein/blob/main/README.md Install the dynein CLI on macOS or Linux systems using the Homebrew package manager. This command simplifies the installation process. ```bash brew install dynein ``` -------------------------------- ### Install dynein CLI on Linux (x86-64) Source: https://github.com/awslabs/dynein/blob/main/README.md Download and install the dynein CLI for Linux x86-64 by fetching the binary, extracting it, and moving it to `/usr/local/bin/`. Includes a verification step using the `--help` command. ```bash curl -O -L https://github.com/awslabs/dynein/releases/latest/download/dynein-linux.tar.gz tar xzvf dynein-linux.tar.gz sudo mv dy /usr/local/bin/ dy --help ``` -------------------------------- ### Install dynein CLI on macOS Source: https://github.com/awslabs/dynein/blob/main/README.md Download and install the dynein CLI for macOS by downloading the binary, extracting it, and moving it to the system's PATH. Includes verification with `--help` command. ```bash curl -O -L https://github.com/awslabs/dynein/releases/latest/download/dynein-macos.tar.gz tar xzvf dynein-macos.tar.gz mv dy /usr/local/bin/ dy --help ``` -------------------------------- ### Build dynein CLI from Source using Cargo Source: https://github.com/awslabs/dynein/blob/main/README.md Build and install the dynein CLI from its source code using Cargo, Rust's package manager. This method requires Rust to be installed and involves cloning the repository, navigating into it, and running the installation command. ```bash git clone [[this_git_repository_url]] cd dynein cargo install --locked --path . ./target/release/dy --help ``` -------------------------------- ### Basic Table Setup and Querying with Dynein Source: https://github.com/awslabs/dynein/blob/main/docs/query.md This snippet demonstrates the basic workflow for setting up a table and querying items using the 'dy' CLI. It includes creating a table, selecting it for use, putting sample data, and performing a simple query based on the partition key. ```bash dy admin create table query-format --keys pk,S sk,S dy use query-format dy put 0001 01 dy put 0001 02 dy put 0001 11 dy put 0001 12 dy query 0001 ``` -------------------------------- ### Install dynein CLI on macOS (ARM 64) Source: https://github.com/awslabs/dynein/blob/main/README.md Download and install the dynein CLI for macOS ARM 64-bit systems by downloading the specific binary, extracting it, and moving it to the system's PATH. Verification via `--help` is included. ```bash curl -O -L https://github.com/awslabs/dynein/releases/latest/download/dynein-macos-arm.tar.gz tar xzvf dynein-macos-arm.tar.gz mv dy /usr/local/bin/ dy --help ``` -------------------------------- ### Dynein Non-Strict Query Example (Bash) Source: https://github.com/awslabs/dynein/blob/main/docs/query.md Demonstrates how to use Dynein's non-strict format for querying, where the input value does not need to strictly align with the table definition's data type. This format allows for more lenient parsing, which may evolve in the future. It shows examples for less-than-or-equal-to and equality comparisons. ```bash dy query --non-strict 0001 -s '<= 1' dynein understands the above expression the same as follows: dy query --strict 0001 -s '<= "1"' Also, when you want to specify the equal operator, you can specify its value directly. dy query --non-strict 0001 -s '01' It is semantically equivalent to the following command: dy query --strict 0001 -s '= "01"' ``` -------------------------------- ### Bootstrap Sample DynamoDB Tables with Dynein Source: https://github.com/awslabs/dynein/blob/main/README.md The `dy bootstrap` command creates sample DynamoDB tables with predefined schemas and populates them with sample data. It also provides example commands to interact with the bootstrapped tables. The available sample tables can be listed using `dy bootstrap --list`. ```bash $ dy bootstrap Bootstrapping - dynein will creates 4 sample tables defined here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AppendixSampleTables.html 'ProductCatalog' - simple primary key table Id (N) 'Forum' - simple primary key table Name (S) 'Thread' - composite primary key table ForumName (S) Subject (S) 'Reply' - composite primary key table, with GSI named 'PostedBy-Message-Index' Id (S) ReplyDateTime (S) ...(snip logs)... Now all tables have sample data. Try following commands to play with dynein. Enjoy! $ dy --region us-west-2 ls $ dy --region us-west-2 desc --table Thread $ dy --region us-west-2 scan --table Thread $ dy --region us-west-2 use --table Thread $ dy scan After you 'use' a table like above, dynein assume you're using the same region & table, which info is stored at ~/.dynein/config.yml and ~/.dynein/cache.yml Let's move on with the 'us-west-2' region you've just 'use'd... $ dy scan --table Forum $ dy scan -t ProductCatalog $ dy get -t ProductCatalog 101 $ dy query -t Reply "Amazon DynamoDB#DynamoDB Thread 2" $ dy query -t Reply "Amazon DynamoDB#DynamoDB Thread 2" --sort-key "begins_with 2015-10" ``` -------------------------------- ### Dynein Format: String Type Examples Source: https://github.com/awslabs/dynein/blob/main/docs/format.md Demonstrates string representation in Dynein format using both single and double quotes. Supports UTF-8 encoding and escape sequences when double quotes are used. ```bash dy put 15 -i '{"date":"2022-02-22T22:22:22Z"}' ``` ```bash dy put 16 -i "{'date':'2022-02-22T22:22:22Z'}" ``` -------------------------------- ### Bootstrap DynamoDB tables and load test data Source: https://github.com/awslabs/dynein/blob/main/tests/cmd/bootstrap.md This command creates sample DynamoDB tables and populates them with test data. It allows specifying the AWS region, port for local DynamoDB instances, and the target table name. You can also list available samples using the --list option. It requires the 'dynein' CLI to be installed. ```bash $ dy bootstrap --help Create sample tables and load test data for bootstrapping Usage: dy bootstrap [OPTIONS] Options: -l, --list -s, --sample -r, --region The region to use (e.g. --region us-east-1). When using DynamodB Local, use `--region local`. You can use --region option in both top-level and subcommand-level. -p, --port Specify the port number. This option has an effect only when `--region local` is used. -t, --table Target table of the operation. You can use --table option in both top-level and subcommand-level. You can store table schema locally by executing `$ dy use`, after that you need not to specify --table on every command. -h, --help Print help $ dy help bootstrap Create sample tables and load test data for bootstrapping Usage: dy bootstrap [OPTIONS] Options: -l, --list -s, --sample -r, --region The region to use (e.g. --region us-east-1). When using DynamodB Local, use `--region local`. You can use --region option in both top-level and subcommand-level. -p, --port Specify the port number. This option has an effect only when `--region local` is used. -t, --table
Target table of the operation. You can use --table option in both top-level and subcommand-level. You can store table schema locally by executing `$ dy use`, after that you need not to specify --table on every command. -h, --help Print help ``` -------------------------------- ### Import DynamoDB Items with Dynein Source: https://github.com/awslabs/dynein/blob/main/README.md Explains how to import data into a DynamoDB table using the `dy import` command. It covers importing from a JSON file and specifies that JSON is the default format. An example command is provided. ```bash $ dy import --table target_movie --format json --input-file movie.json ``` -------------------------------- ### Dynein Format: Boolean Type Example Source: https://github.com/awslabs/dynein/blob/main/docs/format.md Illustrates the usage of boolean type attributes in Dynein format, accepting either 'true' or 'false' values. ```bash dy put 5 -i '{"true-field": true, "false-field": false}' ``` -------------------------------- ### Binary Set in Dynein Source: https://github.com/awslabs/dynein/blob/main/docs/format.md Provides an example of storing a binary set using Dynein. Binary sets are defined with `<< ... >>` and can include binary literals (like `b"\x00"`) and base64 encoded strings. All elements must be binary. ```bash dy put 37 -i '{"binary-set": <>}' ``` -------------------------------- ### Dynein Interactive Shell Mode Source: https://context7.com/awslabs/dynein/llms.txt Demonstrates how to enter and use Dynein's interactive shell mode for executing multiple commands without retyping 'dy'. The shell maintains context like the current table and region between commands. Includes examples for using commands, setting context, and exiting the shell. ```bash # Start shell mode dynein --shell # Now execute commands directly: dynein> use Movie --region us-west-2 dynein> scan --limit 5 dynein> get 1958 "Touch of Evil" dynein> query 1960 dynein> put 2024 "New Movie" --item '{"rating": 8.5}' dynein> exit ``` -------------------------------- ### Dynein Format: Null Type Example Source: https://github.com/awslabs/dynein/blob/main/docs/format.md Demonstrates how to represent a null value in Dynein format using the 'null' keyword. This is used for attributes with unknown or undefined states. ```bash dy put 1 -i '{"null-field": null}' ``` -------------------------------- ### Export DynamoDB Items to CSV Source: https://github.com/awslabs/dynein/blob/main/README.md Illustrates exporting DynamoDB items to a CSV file using the `dy export` command. It demonstrates exporting only specified attributes in addition to the primary keys. Includes an example of the CSV output. ```bash $ dy export --table Reply --output-file out.csv --format csv --attributes PostedBy,Message $ cat out.csv Id,ReplyDateTime,PostedBy,Message "Amazon DynamoDB#DynamoDB Thread 1","2015-09-15T19:58:22.947Z","User A","DynamoDB Thread 1 Reply 1 text" ... ``` -------------------------------- ### Dynein Format: Number Type Examples Source: https://github.com/awslabs/dynein/blob/main/docs/format.md Shows how to represent various number types, including integers, fractions, negative numbers, and exponential notation, in Dynein format. Numbers must be decimal and support up to 38 digits of precision. ```bash dy put 10 -i '{"integer": 1, "fraction": 0.1, "minus": -3, "exponential": -1.23e-3}' ``` -------------------------------- ### Batch Write Items with Dynein using --put and --del Options Source: https://github.com/awslabs/dynein/blob/main/README.md Demonstrates using the `dy bwrite` command with `--put` and `--del` options to add and remove items individually. This method requires specifying at least a primary key for each item. Examples show combining these options and using them with `--input`. ```bash $ dy bwrite --put '{"pk": "1", "this_is_set": <<"i","j","k">>}' --put '{"pk": "2", "this_is_set": <<"x","y","z">>}' $ dy scan pk attributes 1 {"this_is_set":["i","j","k"]} 2 {"this_is_set":["x","y","z"]} $ dy bwrite --del '{"pk": "1"}' --del '{"pk": "2"}' --put '{"pk": "3", "this_is_set": <<"a","b","c">>}' $ dy scan pk attributes 3 {"this_is_set":["a","b","c"]} $ dy bwrite --del '{"pk": "1"}' --del '{"pk": "2"}' --put '{"pk": "3", "this_is_set": <<"a","b","c">>}' --input request.json ``` -------------------------------- ### Create DynamoDB Table using Dynein Admin Source: https://github.com/awslabs/dynein/blob/main/README.md The `dy admin create table` command is used to create a new DynamoDB table. This example demonstrates creating a table named `mytable` with a primary key `pk` of type String (S). This command interfaces with the AWS SDK's CreateTable API. ```bash $ dy admin create table mytable --keys pk,S ``` -------------------------------- ### Export DynamoDB Items to JSON and JSONL Source: https://github.com/awslabs/dynein/blob/main/README.md Shows how to export items from a DynamoDB table to JSON and JSON Lines (JSONL) formats using the `dy export` command. Covers default JSON export, compact JSON, and the JSONL format for one JSON item per line. It also includes example output. ```bash $ dy export --table Reply --format json --output-file out.json $ cat out.json [ { "PostedBy": "User A", "ReplyDateTime": "2015-09-15T19:58:22.947Z", "Id": "Amazon DynamoDB#DynamoDB Thread 1", "Message": "DynamoDB Thread 1 Reply 1 text" }, { "Id": "Amazon DynamoDB#DynamoDB Thread 1", ... ``` ```bash $ dy export --table Reply --format jsonl --output-file out.jsonl $ cat out.jsonl {"PostedBy":"User A","ReplyDateTime":"2015-09-15T19:58:22.947Z","Message":"DynamoDB Thread 1 Reply 1 text","Id":"Amazon DynamoDB#DynamoDB Thread 1"} {"PostedBy":"User B","Message":"DynamoDB Thread 1 Reply 2 text","ReplyDateTime":"2015-09-22T19:58:22.947Z","Id":"Amazon DynamoDB#DynamoDB Thread 1"} ... ``` -------------------------------- ### Bootstrap Sample DynamoDB Tables Source: https://context7.com/awslabs/dynein/llms.txt Create and populate sample DynamoDB tables with test data. Useful for learning DynamoDB concepts or setting up a test environment quickly. Supports listing available datasets and bootstrapping specific or default sets. ```bash # List available sample datasets dy bootstrap --list # Bootstrap default sample tables (Forum, Thread, Reply, ProductCatalog) dy bootstrap --region us-west-2 # Bootstrap specific sample dataset dy bootstrap --sample movie --region us-west-2 ``` -------------------------------- ### Querying with Sort Key Prefix Condition in Dynein Source: https://github.com/awslabs/dynein/blob/main/docs/query.md This example shows how to use the 'dy query' command with a sort key condition to retrieve items whose sort key starts with a specific prefix. It uses the '-s' option with the 'begins_with' operator. ```bash dy query 0001 -s 'begins_with "0"' ``` -------------------------------- ### Display Dynein Help Information Source: https://github.com/awslabs/dynein/blob/main/README.md The `dy --help` command displays the main help information for the dynein CLI, including usage instructions, available top-level options, and a list of all available subcommands. It also provides information about configuration file locations and the purpose of the tool. ```bash $ dy --help dynein x.x.x dynein is a command line tool to interact with DynamoDB tables/data using concise interface. dynein looks for config files under $HOME/.dynein/ directory. USAGE: dy [OPTIONS] FLAGS: -h, --help Prints help information -V, --version Prints version information OPTIONS: -r, --region The region to use (e.g. --region us-east-1). When using DynamodB Local, use `--region local`. You can use --region option in both top-level and subcommand-level -t, --table
Target table of the operation. You can use --table option in both top-level and subcommand- level. You can store table schema locally by executing `$ dy use`, after that you need not to specify --table on every command SUBCOMMANDS: admin Admin operations such as creating/updating table or GSI backup Take backup of a DynamoDB table using on-demand backup bootstrap Create sample tables and load test data for bootstrapping bwrite Put or Delete multiple items at one time, up to 25 requests. [API: BatchWriteItem] config Manage configuration files (config.yml and cache.yml) from command line del Delete an existing item. [API: DeleteItem] desc Show detailed information of a table. [API: DescribeTable] export Export items from a DynamoDB table and save them as CSV/JSON file get Retrieve an item by specifying primary key(s). [API: GetItem] help Prints this message or the help of the given subcommand(s) import Import items into a DynamoDB table from CSV/JSON file list List tables in the region. [API: ListTables] put Create a new item, or replace an existing item. [API: PutItem] query Retrieve items that match conditions. Partition key is required. [API: Query] restore Restore a DynamoDB table from backup data scan Retrieve items in a table without any condition. [API: Scan] upd Update an existing item. [API: UpdateItem] use Switch target table context. After you use the command you don't need to specify table every time, but you may overwrite the target table with --table (-t) option ``` -------------------------------- ### Get a Single DynamoDB Item by Primary Key using dy get Source: https://github.com/awslabs/dynein/blob/main/README.md Retrieves the full details of a single DynamoDB item using the 'dy get' command. Requires the partition key and sort key for composite primary keys. If the table has a simple primary key, only the partition key is needed. This command is useful for inspecting individual records after scanning or for targeted data retrieval. ```bash $ dy get 1958 "Touch of Evil" { "info": { "actors": [ "Charlton Heston", "Janet Leigh", "Orson Welles" ], "directors": [ "Orson Welles" ], "genres": [ "Crime", "Film-Noir", "Thriller" ], "image_url": "http://ia.media-imdb.com/images/M/MV5BNjMwODI0ODg1Nl5BMl5BanBnXkFtZTcwMzgzNjk3OA@@._V1_SX400_.jpg", "plot": "A stark, perverse story of murder, kidnapping, and police corruption in a Mexican border town.", "rank": 3843, "rating": 8.2, "release_date": "1958-04-23T00:00:00Z", "running_time_secs": 5700 }, "title": "Touch of Evil", "year": 1958 } ``` -------------------------------- ### Manage DynamoDB Table State and Data with Dynein Source: https://github.com/awslabs/dynein/blob/main/README.md Shows how to set the current table context using `dy use`, describe the active table's status, put an item into the table, and scan all items in the table. This illustrates basic data manipulation after a table is active and ready. ```bash $ dy use app_users $ dy desc --- name: app_users region: us-east-1 status: ACTIVE schema: pk: app_id (S) sk: user_id (S) mode: OnDemand capacity: ~ gsi: ~ lsi: ~ stream: ~ count: 0 size_bytes: 0 created_at: "2020-03-03T13:34:43+00:00" $ dy put myapp 1234 --item '{"rank": 99}' Successfully put an item to the table 'app_users'. $ dy scan app_id user_id attributes myapp 1234 {"rank":99} ``` -------------------------------- ### GET Item with Composite Primary Key Source: https://github.com/awslabs/dynein/blob/main/README.md Retrieves a full item from a DynamoDB table using its composite primary key (partition key and sort key). This command is useful when the default scan results are trimmed. ```APIDOC ## GET /item ### Description Retrieves a single item from a DynamoDB table using its composite primary key. ### Method GET ### Endpoint `/item` ### Parameters #### Path Parameters - **year** (Number) - Required - The partition key of the item. - **title** (String) - Required - The sort key of the item. ### Request Example ```bash $ dy get 1958 "Touch of Evil" ``` ### Response #### Success Response (200) - **year** (Number) - The partition key of the item. - **title** (String) - The sort key of the item. - **info** (Object) - Contains detailed information about the movie, including actors, directors, plot, etc. #### Response Example ```json { "info": { "actors": [ "Charlton Heston", "Janet Leigh", "Orson Welles" ], "directors": [ "Orson Welles" ], "genres": [ "Crime", "Film-Noir", "Thriller" ], "image_url": "http://ia.media-imdb.com/images/M/MV5BNjMwODI0ODg1Nl5BMl5BanBnXkFtZTcwMzgzNjk3OA@@._V1_SX400_.jpg", "plot": "A stark, perverse story of murder, kidnapping, and police corruption in a Mexican border town.", "rank": 3843, "rating": 8.2, "release_date": "1958-04-23T00:00:00Z", "running_time_secs": 5700 }, "title": "Touch of Evil", "year": 1958 } ``` ``` -------------------------------- ### Create Global Secondary Index with Dynein Source: https://github.com/awslabs/dynein/blob/main/README.md Demonstrates how to add a Global Secondary Index (GSI) to an existing DynamoDB table using the `dy admin create index` command. It shows the command syntax, the resulting table status update, and how to query using the new index. ```bash $ dy admin create index top_rank_users_index --keys rank,N --table app_users --- name: app_users region: us-west-2 status: UPDATING schema: pk: app_id (S) sk: user_id (S) mode: OnDemand capacity: ~ gsi: - name: top_rank_users_index schema: pk: rank (N) sk: ~ capacity: ~ lsi: ~ stream: ~ count: 0 size_bytes: 0 created_at: "2020-06-02T14:22:56+00:00" $ dy use app_users $ dy scan --index top_rank_users_index ``` -------------------------------- ### Dynein Format: String Escape Sequences Source: https://github.com/awslabs/dynein/blob/main/docs/format.md Provides an example of using escape sequences within double-quoted strings in Dynein format, such as newline and tab characters. Note that escape sequences are not supported with single quotes. ```bash dy put 17 -i '{"escape":"\"hello\",\tworld!\n"}' ``` -------------------------------- ### Create Table Source: https://context7.com/awslabs/dynein/llms.txt Creates a new DynamoDB table with specified partition and optional sort keys. ```APIDOC ## Create Table ### Description Create a new DynamoDB table with specified partition and optional sort keys. ### Method POST ### Endpoint /admin/create_table ### Parameters #### Path Parameters - **table_name** (string) - Required - The name of the table to create. #### Query Parameters - **--keys** (string) - Required - Comma-separated list of keys, each with a type (S=String, N=Number, B=Binary). Format: `partition_key_name,Type [sort_key_name,Type]` - **--region** (string) - Optional - Specify the AWS region for table creation. ### Request Example ```bash # Create table with partition key only dy admin create table my_users --keys user_id,S # Create table with partition and sort keys dy admin create table app_users --keys app_id,S user_id,N # Full example with region dy admin create table products --keys product_id,N --region us-east-1 ``` ### Response #### Success Response (200) - Returns details of the created table, including name, region, status, schema, and creation timestamp. #### Response Example ```json { "name": "products", "region": "us-east-1", "status": "CREATING", "schema": { "pk": "product_id (N)", "sk": "~" }, "mode": "OnDemand", "capacity": "~", "gsi": "~", "created_at": "2024-01-15T10:30:00+00:00" } ``` ``` -------------------------------- ### Create DynamoDB Table Imperatively with Dynein Source: https://github.com/awslabs/dynein/blob/main/README.md This command demonstrates how to imperatively create a DynamoDB table named 'app_users' using Dynein. It specifies the primary key schema (app_id as partition key, user_id as sort key) and uses On-Demand billing mode. The output shows the initial state of the created table. ```bash $ dy admin create table app_users --keys app_id,S user_id,S --- name: app_users region: us-east-1 status: CREATING schema: pk: app_id (S) sk: user_id (S) mode: OnDemand capacity: ~ gsi: ~ lsi: ~ stream: ~ count: 0 size_bytes: 0 created_at: "2020-03-03T13:34:43+00:00" ``` -------------------------------- ### Calculate Fibonacci Sequence with Dynein Source: https://github.com/awslabs/dynein/blob/main/README.md This snippet shows how to calculate Fibonacci numbers using the `dy upd` command to update attributes representing the previous two numbers in the sequence and `dy get` to retrieve the current values. It demonstrates iterative updates to generate the sequence. ```bash $ dy upd 42 --set "n1 = n2, n2 = n1 + n2" $ dy get 42 | jq -c '[.n1,.n2]' [1,1] $ dy upd 42 --set "n1 = n2, n2 = n1 + n2" $ dy get 42 | jq -c '[.n1,.n2]' [1,2] $ dy upd 42 --set "n1 = n2, n2 = n1 + n2" $ dy get 42 | jq -c '[.n1,.n2]' [2,3] $ dy upd 42 --set "n1 = n2, n2 = n1 + n2" $ dy get 42 | jq -c '[.n1,.n2]' [3,5] $ dy upd 42 --remove "n1,n2" $ dy get 42 { "id": "42" } ``` -------------------------------- ### Create DynamoDB Table (Bash) Source: https://context7.com/awslabs/dynein/llms.txt Creates a new DynamoDB table with specified partition and optional sort keys. Supports different data types for keys and allows specifying region and other table configurations. Dependencies: dynein CLI. ```bash # Create table with partition key only (S=String, N=Number, B=Binary) dy admin create table my_users --keys user_id,S # Create table with partition and sort keys dy admin create table app_users --keys app_id,S user_id,N # Full example with output: dy admin create table products --keys product_id,N --region us-east-1 # Output: # --- # name: products # region: us-east-1 # status: CREATING # schema: # pk: product_id (N) # sk: ~ # mode: OnDemand # capacity: ~ # gsi: ~ # created_at: "2024-01-15T10:30:00+00:00" ``` -------------------------------- ### List DynamoDB Tables with Dynein Source: https://github.com/awslabs/dynein/blob/main/README.md The `dy ls --all-regions` command lists all DynamoDB tables across all available AWS regions. It connects to AWS and retrieves table names, displaying them grouped by region. This command is useful for getting an overview of all your DynamoDB resources. ```bash $ dy ls --all-regions DynamoDB tables in region: us-west-2 EventData EventUsers * Forum Thread DynamoDB tables in region: us-west-1 No table in this region. DynamoDB tables in region: us-east-2 UserBooks Users ... ``` -------------------------------- ### List DynamoDB Tables (Bash) Source: https://context7.com/awslabs/dynein/llms.txt Lists DynamoDB tables in the configured region, all regions, or a specific region. Output is a formatted list of table names. Dependencies: dynein CLI. ```bash # List tables in configured region dy list # List tables in all AWS regions dy list --all-regions # List tables in specific region dy --region us-west-2 list # Output example: # DynamoDB tables in region: us-west-2 # EventData # EventUsers # * Forum # Thread ``` -------------------------------- ### Describe Table Source: https://context7.com/awslabs/dynein/llms.txt Shows detailed information about a DynamoDB table, including schema, indexes, and capacity settings. ```APIDOC ## Describe Table ### Description Show detailed information about a table including schema, indexes, and capacity settings. ### Method GET ### Endpoint /describe_table ### Parameters #### Path Parameters - **table_name** (string) - Optional - The name of the table to describe. If not provided, describes the currently selected table. #### Query Parameters - **--region** (string) - Optional - Specify the AWS region of the table. - **--all-tables** (boolean) - Optional - Describe all tables in the specified or configured region. ### Request Example ```bash # Describe currently selected table dy desc # Describe specific table dy desc Forum --region us-west-2 # Describe all tables in region dy desc --all-tables ``` ### Response #### Success Response (200) - Returns detailed information about the table(s), including name, region, status, schema, capacity, indexes, item count, size, and creation timestamp. #### Response Example ```json { "name": "Forum", "region": "us-west-2", "status": "ACTIVE", "schema": { "pk": "Name (S)", "sk": "~" }, "mode": "OnDemand", "gsi": [ { "name": "CategoryIndex", "schema": { "pk": "Category (S)" } } ], "count": 42, "size_bytes": 8192, "created_at": "2024-01-01T00:00:00+00:00" } ``` ``` -------------------------------- ### Get Item from DynamoDB using Dynein CLI Source: https://context7.com/awslabs/dynein/llms.txt Retrieves a single item from a DynamoDB table using its primary key(s). Supports partition key only, or partition and sort keys. Allows specifying consistent read and output formats (JSON, YAML, or raw DynamoDB JSON). ```bash dy get 101 --table ProductCatalog dy get 1958 "Touch of Evil" --table Movie dy get "user123" --consistent-read dy get 101 --output json dy get 101 --output yaml dy get 101 --output raw ``` -------------------------------- ### Import with Set Type Inference Disabled (Default) Source: https://github.com/awslabs/dynein/blob/main/README.md Demonstrates the default behavior of `dy import` without the `--enable-set-inference` flag. In this mode, JSON lists are always inferred as DynamoDB lists (type 'L'). This example shows importing JSONL data and the resulting DynamoDB item structure. ```bash $ cat load.json {"pk":1,"string-set":["1","2","3"]} {"pk":2,"number-set":[1,2,3]} {"pk":3,"list":["1",2,"3"]} $ dy admin create table target_movie -k pk,N $ dy import --table target_movie --format jsonl --input-file load.json $ aws dynamodb get-item --table-name target_movie --key '{"pk":{"N":"1"}}' { "Item": { "string-set": { "L": [ { "S": "1" }, { "S": "2" }, { "S": "3" } ] }, "pk": { "N": "1" } } } ``` -------------------------------- ### dy put Command Usage and Options Source: https://github.com/awslabs/dynein/blob/main/tests/cmd/put.md This snippet details the command-line usage for 'dy put', including its arguments (Partition Key, Sort Key) and available options. Options allow specifying additional item attributes in JSON format, the AWS region, port for local DynamoDB, and the target table. ```bash $ dy put --help Create a new item, or replace an existing item. [API: PutItem] Usage: dy put [OPTIONS] [SVAL] Arguments: Partition Key of the target item [SVAL] Sort Key of the target item (if any) Options: -i, --item Additional attributes put into the item, which should be valid JSON. e.g. --item '{"name": "John", "age": 18, "like": ["Apple", "Banana"]}' -r, --region The region to use (e.g. --region us-east-1). When using DynamodB Local, use `--region local`. You can use --region option in both top-level and subcommand-level. -p, --port Specify the port number. This option has an effect only when `--region local` is used. -t, --table
Target table of the operation. You can use --table option in both top-level and subcommand-level. You can store table schema locally by executing `$ dy use`, after that you need not to specify --table on every command. -h, --help Print help $ dy help put Create a new item, or replace an existing item. [API: PutItem] Usage: dy put [OPTIONS] [SVAL] Arguments: Partition Key of the target item [SVAL] Sort Key of the target item (if any) Options: -i, --item Additional attributes put into the item, which should be valid JSON. e.g. --item '{"name": "John", "age": 18, "like": ["Apple", "Banana"]}' -r, --region The region to use (e.g. --region us-east-1). When using DynamodB Local, use `--region local`. You can use --region option in both top-level and subcommand-level. -p, --port Specify the port number. This option has an effect only when `--region local` is used. -t, --table
Target table of the operation. You can use --table option in both top-level and subcommand-level. You can store table schema locally by executing `$ dy use`, after that you need not to specify --table on every command. -h, --help Print help ``` -------------------------------- ### Demonstrating Strict Mode Error with Incorrect Type in Dynein Source: https://github.com/awslabs/dynein/blob/main/docs/query.md This example shows how Dynein's strict mode handles type mismatches in sort key conditions. Providing a raw number when a string is expected results in an error, highlighting the importance of correct type specification. ```bash dy query --strict 0001 -s '<= 1' ``` -------------------------------- ### Describe DynamoDB Table (Bash) Source: https://context7.com/awslabs/dynein/llms.txt Retrieves and displays detailed information about a DynamoDB table, including its schema, indexes, capacity settings, item count, and size. Can describe the currently selected table, a specific table, or all tables in a region. Dependencies: dynein CLI. ```bash # Describe currently selected table dy desc # Describe specific table dy desc Forum --region us-west-2 # Describe all tables in region dy desc --all-tables # Output format: # --- # name: Forum # region: us-west-2 # status: ACTIVE # schema: # pk: Name (S) # sk: ~ # mode: OnDemand # gsi: # - name: CategoryIndex # schema: # pk: Category (S) # count: 42 # size_bytes: 8192 # created_at: "2024-01-01T00:00:00+00:00" ``` -------------------------------- ### Dynein Format: Heredoc Input Source: https://github.com/awslabs/dynein/blob/main/docs/format.md Illustrates using a heredoc to input complex Dynein format structures, including both escaped and raw strings, from standard input. ```bash dy put 19 -i "$(cat < Admin operations such as creating/updating table or GSI USAGE: dy admin [OPTIONS] FLAGS: ... OPTIONS: ... SUBCOMMANDS: create Create new DynamoDB table or GSI. [API: CreateTable, UpdateTable] delete Delete a DynamoDB table or GSI. [API: DeleteTable] desc Show detailed information of a table. [API: DescribeTable] help Prints this message or the help of the given subcommand(s) list List tables in the region. [API: ListTables] update Update a DynamoDB table. [API: UpdateTable etc] ``` -------------------------------- ### Batch Write Items with Dynein using JSON Input Source: https://github.com/awslabs/dynein/blob/main/README.md Illustrates how to use the `dy bwrite --input` command to perform batch put and delete operations by specifying operations in a JSON file that conforms to the BatchWriteItem API Request Syntax. ```bash $ dy bwrite --input request.json { "__TABLE_NAME__": [ { "PutRequest": { "Item": { "pk": { "S": "ichi" }, "ISBN": { "S": "111-1111111111" }, "Price": { "N": "2" }, "Dimensions": { "SS": ["Giraffe", "Hippo" ,"Zebra"] }, "PageCount": { "NS": ["42.2", "-19", "7.5", "3.14"] }, "InPublication": { "BOOL": false }, "Binary": {"B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"}, "BinarySet": {"BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]}, "Nothing": { "NULL": true }, "Authors": { "L": [ { "S": "Author1" }, { "S": "Author2" }, { "N": "42" } ] }, "Details": { "M": { "Name": { "S": "Joe" }, "Age": { "N": "35" }, "Misc": { "M": { "hope": { "BOOL": true }, "dream": { "L": [ { "N": "35" }, { "NULL": true } ] } } } } } } } } ] } ```