Questions tagged [pynamodb]

34 questions
1
vote
1 answer

How to create a read-only model attribute in pynamodb?

I'm working on a model which implements a read-only attribute with a simple hack: from pynamodb.models import Model class MyModel(Model): […] updated_at = UTCDateTimeAttribute() def save(self): self.updated_at =…
l0b0
  • 55,365
  • 30
  • 138
  • 223
1
vote
1 answer

Error while using Global Secondary index in dynamodb in python

I have created a global secondary index in AWS dynamodb where In user table in which I am using the phone as GSI. I am getting an error with the message: 'Table UsersTable has no index: PHONE_INDEX'. Below is the code snippet for the user table and…
shelam
  • 11
  • 4
1
vote
0 answers

'NoneType' object is not iterable when creating dynamodb record using pynamodb library

I am trying to create and save the record to DynamoDB ServiceStateModel( instance_id=service_request["instance_id"], plan_id=service_request["plan_id"], service_id=service_request["service_id"], …
lapots
  • 12,553
  • 32
  • 121
  • 242
0
votes
1 answer

issue with setting dynamo db created_at field

I am trying to add a new field 'created_time' in my existing dynamodb. another field 'updated_time' field already exists. I want to set the created_time only once, when the new record is created. updated_time updates at every change in record using…
Frid-j
  • 25
  • 5
0
votes
2 answers

DynamoDb AccessDeniedException when apparently making identical queries to table

I have two API calls to the BE that are fired simultaneously. Both access the same record in a DynamoDb table. 90% of the time, there is no issue. 10% of the time, I get the following error: pynamodb.exceptions.QueryError: Failed to query items: An…
alitaleg
  • 165
  • 2
  • 11
0
votes
1 answer

Why is PynamoDB Not projecting attributes from the main table in my query results?

I've got a PynamoDB table and index mapping defined as follows: class Id2Index(LocalSecondaryIndex): class Meta: projection = AllProjection() kind = UnicodeAttribute(hash_key=True) id2 = UnicodeAttribute(range_key=True) class…
CryptoFool
  • 21,719
  • 5
  • 26
  • 44
0
votes
0 answers

Pynamodb create model from nested json

how I can create model from nested json in pynamodb? For example: { “user profile”: { “Name”:”test”, “born”:{ “year”:”2023” } }, … }
Andrii
  • 11
  • 3
0
votes
0 answers

Pynamodb: how do I create a Map of Sets from a dict?

I have a DynamoDB table where I want the items to have a field that is a map of a set of strings. I want to create this from a top level map like this: kv_by_aws_account: Dict[str, Dict[str, Set[str]]] = { "111111111111": { "k1": { …
John
  • 10,837
  • 17
  • 78
  • 141
0
votes
0 answers

PynamoDB TransactWrite NoCredentialError

I'm trying to TransactWrite using PynamoDB. But, I'm getting botocore.exceptions.NoCredentialsError: Unable to locate credentials error. I am sending a request to DynamoDB from local PC. And, since MFA is applied to the locally stored AWS Profile, I…
Seung-hee Han
  • 75
  • 1
  • 9
0
votes
0 answers

Pynamodb Transaction not using local endpoint

Regardless of whatever I tried, pynamodb is not connecting to my local dynamodb. Below is my model, class OrderMarker(Model): class Meta: table_name = 'ddb_mrker_table' connection = TableConnection(table_name='ddb_mrker_table',…
Jimson James
  • 2,937
  • 6
  • 43
  • 78
0
votes
1 answer

Can I create a Model from a TableConnection in PynamoDB?

I have existing DynamoDB tables created through an infrastructure-as-code implementation. Within my application I would like to use the Model abstraction for this existing table. I used TableConnection to connect to the existing table and run the…
Jason Strimpel
  • 14,670
  • 21
  • 76
  • 106
0
votes
2 answers

PynamoDB same model with multipe databases

The way PynamoDB is implemented is that it looks to a specific single DynamoDB table: class UserModel(Model): class Meta: # Specific table. table_name = 'dynamodb-user' region = 'us-west-1' The way my infrastructure…
0
votes
1 answer

PynamoDB Creating GSI and LSI Python Error

Hello All hope you are fine i am reaching out for some help as I am learning and experimenting with pynamodb Goal to create LSI and GSI Phase 1: create index and popular with fake data import os import boto3 import json from faker import…
0
votes
1 answer

Pynamodb | Dynamodb

Hey i am pretty new to the pynamodb, i want to know how to use pre-existing table in pynamodb without re-writing the models defination. from pynamodb.connection import Connection # Get a connection conn = Connection(host='http://localhost:8000') #…
Raj Shah
  • 48
  • 3
  • 10
0
votes
1 answer

Saving object creation datetime using Pynamodb

I want to update the creation_datetime only when a new object is created and update the last_update_datetime on every update while using the save method. default_for_new is updating time even when the existing object is updating. any…
suresh
  • 1
  • 2