当前位置: 首页>>代码示例>>Python>>正文


Python TableConnection.describe_table方法代码示例

本文整理汇总了Python中pynamodb.connection.TableConnection.describe_table方法的典型用法代码示例。如果您正苦于以下问题:Python TableConnection.describe_table方法的具体用法?Python TableConnection.describe_table怎么用?Python TableConnection.describe_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynamodb.connection.TableConnection的用法示例。


在下文中一共展示了TableConnection.describe_table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_batch_get_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_batch_get_item(self):
        """
        TableConnection.batch_get_item
        """
        items = []
        conn = TableConnection(self.test_table_name)
        for i in range(10):
            items.append({"ForumName": "FooForum", "Subject": "thread-{0}".format(i)})
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        with patch(PATCH_METHOD) as req:
            req.return_value = {}
            conn.batch_get_item(items)
            params = {
                "ReturnConsumedCapacity": "TOTAL",
                "RequestItems": {
                    self.test_table_name: {
                        "Keys": [
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-0"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-1"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-2"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-3"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-4"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-5"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-6"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-7"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-8"}},
                            {"ForumName": {"S": "FooForum"}, "Subject": {"S": "thread-9"}},
                        ]
                    }
                },
            }
            self.assertEqual(req.call_args[0][1], params)
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:37,代码来源:test_table_connection.py

示例2: test_query

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
 def test_query(self):
     """
     TableConnection.query
     """
     conn = TableConnection(self.test_table_name)
     with patch(PATCH_METHOD) as req:
         req.return_value = HttpOK(), DESCRIBE_TABLE_DATA
         conn.describe_table()
     with patch(PATCH_METHOD) as req:
         req.return_value = HttpOK(), {}
         conn.query(
             "FooForum",
             key_conditions={'ForumName': {'ComparisonOperator': 'BEGINS_WITH', 'AttributeValueList': ['thread']}},
             exclusive_start_key="test_start_key"
         )
         params = {
             'return_consumed_capacity': 'TOTAL',
             'key_conditions': {
                 'ForumName': {
                     'ComparisonOperator': 'BEGINS_WITH', 'AttributeValueList': [{
                         'S': 'thread'
                     }]
                 }
             },
             'table_name': self.test_table_name,
             'exclusive_start_key': {'ForumName': {'S': 'test_start_key'}}
         }
         self.assertEqual(req.call_args[1], params)
开发者ID:mpresh,项目名称:PynamoDB,代码行数:30,代码来源:test_table_connection.py

示例3: test_delete_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_delete_item(self):
        """
        TableConnection.delete_item
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        with patch(PATCH_METHOD) as req:
            req.return_value = {}
            conn.delete_item(
                "Amazon DynamoDB",
                "How do I update multiple items?")
            params = {
                'ReturnConsumedCapacity': 'TOTAL',
                'Key': {
                    'ForumName': {
                        'S': 'Amazon DynamoDB'
                    },
                    'Subject': {
                        'S': 'How do I update multiple items?'
                    }
                },
                'TableName': self.test_table_name
            }
            self.assertEqual(req.call_args[0][1], params)
开发者ID:BCVisin,项目名称:PynamoDB,代码行数:29,代码来源:test_table_connection.py

示例4: test_query

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
 def test_query(self):
     """
     TableConnection.query
     """
     conn = TableConnection(self.test_table_name)
     with patch(PATCH_METHOD) as req:
         req.return_value = DESCRIBE_TABLE_DATA
         conn.describe_table()
     with patch(PATCH_METHOD) as req:
         req.return_value = {}
         conn.query(
             "FooForum",
             key_conditions={'ForumName': {'ComparisonOperator': 'BEGINS_WITH', 'AttributeValueList': ['thread']}}
         )
         params = {
             'ReturnConsumedCapacity': 'TOTAL',
             'KeyConditions': {
                 'ForumName': {
                     'ComparisonOperator': 'BEGINS_WITH', 'AttributeValueList': [{
                         'S': 'thread'
                     }]
                 }
             },
             'TableName': self.test_table_name
         }
         self.assertEqual(req.call_args[0][1], params)
开发者ID:BCVisin,项目名称:PynamoDB,代码行数:28,代码来源:test_table_connection.py

示例5: test_query

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_query(self):
        """
        TableConnection.query
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        with patch(PATCH_METHOD) as req:
            req.return_value = {}
            conn.query(
                "FooForum",
                Path('Subject').startswith('thread')
            )
            params = {
                'ReturnConsumedCapacity': 'TOTAL',
                'KeyConditionExpression': '(#0 = :0 AND begins_with (#1, :1))',
                'ExpressionAttributeNames': {
                    '#0': 'ForumName',
                    '#1': 'Subject'
                },
                'ExpressionAttributeValues': {
                    ':0': {
                        'S': 'FooForum'
                    },
                    ':1': {
                        'S': 'thread'
                    }
                },
                'TableName': self.test_table_name
            }
            self.assertEqual(req.call_args[0][1], params)

        with patch(PATCH_METHOD) as req:
            req.return_value = {}
            conn.query(
                "FooForum",
                key_conditions={'Subject': {'ComparisonOperator': 'BEGINS_WITH', 'AttributeValueList': ['thread']}}
            )
            params = {
                'ReturnConsumedCapacity': 'TOTAL',
                'KeyConditionExpression': '(#0 = :0 AND begins_with (#1, :1))',
                'ExpressionAttributeNames': {
                    '#0': 'ForumName',
                    '#1': 'Subject'
                },
                'ExpressionAttributeValues': {
                    ':0': {
                        'S': 'FooForum'
                    },
                    ':1': {
                        'S': 'thread'
                    }
                },
                'TableName': self.test_table_name
            }
            self.assertEqual(req.call_args[0][1], params)
开发者ID:eukaryote,项目名称:PynamoDB,代码行数:60,代码来源:test_table_connection.py

示例6: test_describe_table

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
 def test_describe_table(self):
     """
     TableConnection.describe_table
     """
     with patch(PATCH_METHOD) as req:
         req.return_value = DESCRIBE_TABLE_DATA
         conn = TableConnection(self.test_table_name)
         conn.describe_table()
         self.assertEqual(conn.table_name, self.test_table_name)
         self.assertEqual(req.call_args[0][1], {"TableName": "ci-table"})
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:12,代码来源:test_table_connection.py

示例7: test_scan

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
 def test_scan(self):
     """
     TableConnection.scan
     """
     conn = TableConnection(self.test_table_name)
     with patch(PATCH_METHOD) as req:
         req.return_value = DESCRIBE_TABLE_DATA
         conn.describe_table()
     with patch(PATCH_METHOD) as req:
         req.return_value = HttpOK(), {}
         conn.scan()
         params = {"ReturnConsumedCapacity": "TOTAL", "TableName": self.test_table_name}
         self.assertEqual(req.call_args[0][1], params)
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:15,代码来源:test_table_connection.py

示例8: test_get_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_get_item(self):
        """
        TableConnection.get_item
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        with patch(PATCH_METHOD) as req:
            req.return_value = GET_ITEM_DATA
            item = conn.get_item("Amazon DynamoDB", "How do I update multiple items?")
            self.assertEqual(item, GET_ITEM_DATA)
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:15,代码来源:test_table_connection.py

示例9: test_scan

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
 def test_scan(self):
     """
     TableConnection.scan
     """
     conn = TableConnection(self.test_table_name)
     with patch(PATCH_METHOD) as req:
         req.return_value = HttpOK(), DESCRIBE_TABLE_DATA
         conn.describe_table()
     with patch(PATCH_METHOD) as req:
         req.return_value = HttpOK(), {}
         conn.scan()
         params = {
             'return_consumed_capacity': 'TOTAL',
             'table_name': self.test_table_name
         }
         self.assertEqual(req.call_args[1], params)
开发者ID:BalanceCareerInc,项目名称:PynamoDB,代码行数:18,代码来源:test_table_connection.py

示例10: test_put_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_put_item(self):
        """
        TableConnection.put_item
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        with patch(PATCH_METHOD) as req:
            req.return_value = {}
            conn.put_item("foo-key", range_key="foo-range-key", attributes={"ForumName": "foo-value"})
            params = {
                "ReturnConsumedCapacity": "TOTAL",
                "TableName": self.test_table_name,
                "Item": {"ForumName": {"S": "foo-value"}, "Subject": {"S": "foo-range-key"}},
            }
            self.assertEqual(req.call_args[0][1], params)

        with patch(PATCH_METHOD) as req:
            req.return_value = {}
            conn.put_item("foo-key", range_key="foo-range-key", attributes={"ForumName": "foo-value"})
            params = {
                "ReturnConsumedCapacity": "TOTAL",
                "Item": {"ForumName": {"S": "foo-value"}, "Subject": {"S": "foo-range-key"}},
                "TableName": self.test_table_name,
            }
            self.assertEqual(req.call_args[0][1], params)

        with patch(PATCH_METHOD) as req:
            req.return_value = HttpOK(), {}
            conn.put_item(
                "foo-key",
                range_key="foo-range-key",
                attributes={"ForumName": "foo-value"},
                conditional_operator="and",
                expected={"ForumName": {"Exists": False}},
            )
            params = {
                "ReturnConsumedCapacity": "TOTAL",
                "Item": {"ForumName": {"S": "foo-value"}, "Subject": {"S": "foo-range-key"}},
                "TableName": self.test_table_name,
                "ConditionalOperator": "AND",
                "Expected": {"ForumName": {"Exists": False}},
            }
            self.assertEqual(req.call_args[0][1], params)
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:48,代码来源:test_table_connection.py

示例11: test_update_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_update_item(self):
        """
        TableConnection.update_item
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        attr_updates = {
            'Subject': {
                'Value': 'foo-subject',
                'Action': 'PUT'
            },
        }

        with patch(PATCH_METHOD) as req:
            req.return_value = HttpOK(), {}
            conn.update_item(
                'foo-key',
                attribute_updates=attr_updates,
                range_key='foo-range-key',
            )
            params = {
                'Key': {
                    'ForumName': {
                        'S': 'foo-key'
                    },
                    'Subject': {
                        'S': 'foo-range-key'
                    }
                },
                'UpdateExpression': 'SET #0 = :0',
                'ExpressionAttributeNames': {
                    '#0': 'Subject'
                },
                'ExpressionAttributeValues': {
                    ':0': {
                        'S': 'foo-subject'
                    }
                },
                'ReturnConsumedCapacity': 'TOTAL',
                'TableName': 'ci-table'
            }
            self.assertEqual(req.call_args[0][1], params)
开发者ID:eukaryote,项目名称:PynamoDB,代码行数:47,代码来源:test_table_connection.py

示例12: test_delete_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_delete_item(self):
        """
        TableConnection.delete_item
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        with patch(PATCH_METHOD) as req:
            req.return_value = {}
            conn.delete_item("Amazon DynamoDB", "How do I update multiple items?")
            params = {
                "ReturnConsumedCapacity": "TOTAL",
                "Key": {"ForumName": {"S": "Amazon DynamoDB"}, "Subject": {"S": "How do I update multiple items?"}},
                "TableName": self.test_table_name,
            }
            self.assertEqual(req.call_args[0][1], params)
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:20,代码来源:test_table_connection.py

示例13: test_put_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_put_item(self):
        """
        TableConnection.put_item
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = HttpOK(), DESCRIBE_TABLE_DATA
            conn.describe_table()

        with patch(PATCH_METHOD) as req:
            req.return_value = HttpOK(), {}
            conn.put_item(
                'foo-key',
                range_key='foo-range-key',
                attributes={'ForumName': 'foo-value'}
            )
            params = {
                'return_consumed_capacity': 'TOTAL',
                'table_name': self.test_table_name,
                'item': {'ForumName': {'S': 'foo-value'}, 'Subject': {'S': 'foo-range-key'}}
            }
            self.assertEqual(req.call_args[1], params)

        with patch(PATCH_METHOD) as req:
            req.return_value = HttpOK(), {}
            conn.put_item(
                'foo-key',
                range_key='foo-range-key',
                attributes={'ForumName': 'foo-value'}
            )
            params = {
                'return_consumed_capacity': 'TOTAL',
                'item': {
                    'ForumName': {
                        'S': 'foo-value'
                    },
                    'Subject': {
                        'S': 'foo-range-key'
                    }
                },
                'table_name': self.test_table_name
            }
            self.assertEqual(req.call_args[1], params)
开发者ID:adamchainz,项目名称:PynamoDB,代码行数:45,代码来源:test_table_connection.py

示例14: test_update_item

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
    def test_update_item(self):
        """
        TableConnection.delete_item
        """
        conn = TableConnection(self.test_table_name)
        with patch(PATCH_METHOD) as req:
            req.return_value = DESCRIBE_TABLE_DATA
            conn.describe_table()

        attr_updates = {"Subject": {"Value": "foo-subject", "Action": "PUT"}}

        with patch(PATCH_METHOD) as req:
            req.return_value = HttpOK(), {}
            conn.update_item("foo-key", attribute_updates=attr_updates, range_key="foo-range-key")
            params = {
                "Key": {"ForumName": {"S": "foo-key"}, "Subject": {"S": "foo-range-key"}},
                "AttributeUpdates": {"Subject": {"Value": {"S": "foo-subject"}, "Action": "PUT"}},
                "ReturnConsumedCapacity": "TOTAL",
                "TableName": "ci-table",
            }
            self.assertEqual(req.call_args[0][1], params)
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:23,代码来源:test_table_connection.py

示例15: test_query

# 需要导入模块: from pynamodb.connection import TableConnection [as 别名]
# 或者: from pynamodb.connection.TableConnection import describe_table [as 别名]
 def test_query(self):
     """
     TableConnection.query
     """
     conn = TableConnection(self.test_table_name)
     with patch(PATCH_METHOD) as req:
         req.return_value = DESCRIBE_TABLE_DATA
         conn.describe_table()
     with patch(PATCH_METHOD) as req:
         req.return_value = {}
         conn.query(
             "FooForum",
             key_conditions={"ForumName": {"ComparisonOperator": "BEGINS_WITH", "AttributeValueList": ["thread"]}},
         )
         params = {
             "ReturnConsumedCapacity": "TOTAL",
             "KeyConditions": {
                 "ForumName": {"ComparisonOperator": "BEGINS_WITH", "AttributeValueList": [{"S": "thread"}]}
             },
             "TableName": self.test_table_name,
         }
         self.assertEqual(req.call_args[0][1], params)
开发者ID:antoinemenini,项目名称:PynamoDB,代码行数:24,代码来源:test_table_connection.py


注:本文中的pynamodb.connection.TableConnection.describe_table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。