Skip to main content

GetItem

get() always maps to DynamoDB's GetItem. Requires the full primary key (PK + SK if the table has a sort key).

Basic Usage

orders = Orders()

# Basic get
order = orders.get(user_id="usr_123", order_id="ord_456")
if order:
print(order["status"])

With Projection

Reduces RCU cost by only fetching specific attributes:

order = orders.get(user_id="usr_123", order_id="ord_456", select=["total", "status"])

Strongly Consistent Read

order = orders.get(user_id="usr_123", order_id="ord_456", consistent=True)

Error Handling

Calling get() without the SK on a table that has one raises MissingKeyError:

from dkmio import MissingKeyError

try:
order = orders.get(user_id="usr_123") # Missing SK!
except MissingKeyError as e:
print(e) # "get() requires the full key. Missing: order_id"

If you only have the PK and want multiple items, use .query() instead.