devicescape / aws_dynamo

AWS DynamoDB Library for C and C++
GNU Lesser General Public License v3.0
23 stars 12 forks source link

Retrive data from amazon dynamo db using c #7

Open amanaf-korewireless opened 8 years ago

amanaf-korewireless commented 8 years ago

iam new in C language. i used aws_dynamo library for amazon dynamo db communication. i successfully created a table using using aws_dynamo library.

Resultent table like this

timestamp | name

101 | manaf

102 | manaf2

But i can't fetch data from db using aws_dynamo library.

This is my code

static int example_get_item(struct aws_handle *aws)
{
    struct aws_dynamo_attribute attributes[] = {
        {
         .name = "name",
         .name_len = strlen("name"),
         .type = AWS_DYNAMO_STRING,
         }
    };
    struct aws_dynamo_get_item_response *r = NULL;
    struct aws_dynamo_attribute *real_name;

    const char *request = "{\
    \"TableName\":\"testTable\",\
    \"Key\":{\
        \"HashKeyElement\":{\"N\":\"101\"}\
    },\
    \"AttributesToGet\":[\
        \"name\"]\
    }";

    r = aws_dynamo_get_item(aws, request, attributes,
                sizeof(attributes) / sizeof(attributes[0]));
    if (r == NULL) {
        return -1;
    }
    if (r->item.attributes == NULL) {
        aws_dynamo_free_get_item_response(r);
        return -1;
    }
    real_name = &(r->item.attributes[0]);
    printf("name = %s \n", real_name->value.string);
    aws_dynamo_free_get_item_response(r);
    return 0;
}

I need to get more than 1000 values from amazon dynamoDb using C code. What is the actual issue?. is this aproach is best for me?

Jantek commented 6 years ago

Hi manafGadgeon,

see here: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html read the paragraph under 'LastEvaluatedKey'

Regards, Jantek