地理标记如何帮助在DynamoDB中存储位置数据

时间:2017-06-28 07:13:07

标签: amazon-web-services amazon-dynamodb dynamo-local

我想在DynamoDB中保存以下历史位置数据:

  • 设备ID
  • 时间戳
  • 纬度
  • 经度

数据库应该满足两个时间戳之间设备ID的位置列表。

地理标记会有帮助吗?

我已按以下方式定义了Location表:



from __future__ import print_function # Python 2/3 compatibility
import boto3

dynamodb = boto3.resource('dynamodb', region_name='us-west-2', endpoint_url="http://localhost:8000")


table = dynamodb.create_table(
    TableName='LocationOne',
    KeySchema=[
        {
            'AttributeName': 'deviceid',
            'KeyType': 'HASH'  #Partition key
        },
        {
            'AttributeName': 'timestamp',
            'KeyType': 'RANGE'  #Sort key
        }
       
    ],
    AttributeDefinitions=[
        {
            'AttributeName': 'deviceid',
            'AttributeType': 'S'
        },
        {
            'AttributeName': 'timestamp',
            'AttributeType': 'N'
        }

    ],
    ProvisionedThroughput={
        'ReadCapacityUnits': 10,
        'WriteCapacityUnits': 10
    }
)




0 个答案:

没有答案