0

这是一个微不足道的问题,但我没有找到有关如何primaryAWS 的 dynamoDB 表中获取的答案。(我知道我们可以从dynamodb对象中获取,但我想直接从dynamodb.Table.

问题: AttributeError: 'dynamodb.Table' object has no attribute 'primary_key'

解决方案:my_table.get_primary_key()

4

1 回答 1

1
import inspect
print(inspect.getmembers(table, lambda a: not (inspect.isroutine(a))))

结果:

[....('attribute_definitions', [{'AttributeName': 'mail', 'AttributeType': 'S'}]), ...]

答案::

def get_primary_key(table):
    return table.attribute_definitions[0]["'AttributeName"]
于 2021-02-18T10:00:50.463 回答