I am trying to take values from a DB table where It has keys as enabled and values as true, false and empty, I want to take only True values from enabled keys and other keys and rows related to it.
Table
id name enabled dept
1 abd TRUE cs
2 cdew FALSE ds
3 sda sd
4 asd TRUE as
I want only enabled = true values from table. how can I do it? without help of pandas? I want like
id name enabled dept
1 abd TRUE cs
4 asd TRUE as
CodePudding user response:
Best thing to do is create a Sparse Index which only had the True values.
To do this, only set enabled
for True values and if False just omit it as DynamoDB is schemaless.
Now create a GSI with the partition or sort key as enabled
, now the GSI will only contain the items you want. To fetch them simply Scan
the GSI.
GSI:
id(pk) enabled(sk) name dept
1 TRUE abd cs
4 TRUE asd as
CodePudding user response:
I solved it using below code. thanks all for your help
resp= key.get('enabled',None)
if resp: