我正在使用带有boto的Dynamodb2。我的架构定义如下:
schema=[
HashKey('id', data_type=NUMBER),
]
要插入id字段,我使用Python的uuid生成一个随机id,命令为uuid.uuid1(),如下所示:
id = int(uuid.uuid1())
但是当我尝试在表中插入ID时,我收到以下错误:
{
"error_message": "BotoClientError: Inexact numeric for `144095370333333371533171708191171526873`\nNone",
"traceback": "Traceback (most recent call last):\n\n File \"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 195, in wrapper\n response = callback(request, *args, **kwargs)\n\n File \"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 426, in dispatch_list\n return self.dispatch('list', request, **kwargs)\n\n File \"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 458, in dispatch\n response = method(request, **kwargs)\n\n File \"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 1320, in post_list\n updated_bundle = self.obj_create(bundle, **self.remove_api_resource_names(kwargs))\n\n File \"/home/sudip/phunka/projects/freelance/2youtubestats/ViewsApp/myapi.py\", line 186, in obj_create\n returned_id = form.save()\n\n File \"/home/sudip/phunka/projects/freelance/2youtubestats/ViewsApp/forms.py\", line 88, in save\n save_single_video(final_data)\n\n File \"/home/sudip/phunka/projects/freelance/2youtubestats/ViewsApp/dynamo_operations.py\", line 141, in save_single_video\n main_table.put_item(data=data)\n\n File \"/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/table.py\", line 491, in put_item\n return item.save(overwrite=overwrite)\n\n File \"/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/items.py\", line 439, in save\n final_data = self.prepare_full()\n\n File \"/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/items.py\", line 320, in prepare_full\n final_data[key] = self._dynamizer.encode(value)\n\n File \"/usr/local/lib/python2.7/dist-packages/boto/dynamodb/types.py\", line 234, in encode\n return {dynamodb_type: encoder(attr)}\n\n File \"/usr/local/lib/python2.7/dist-packages/boto/dynamodb/types.py\", line 250, in _encode_n\n raise DynamoDBNumberError(msg)\n\nDynamoDBNumberError: BotoClientError: Inexact numeric for `144095370333333371533171708191171526873`\nNone\n"
}
我错过了什么吗?
答案 0 :(得分:2)