<legend id='2hOX4'><style id='2hOX4'><dir id='2hOX4'><q id='2hOX4'></q></dir></style></legend>

        • <bdo id='2hOX4'></bdo><ul id='2hOX4'></ul>

        <small id='2hOX4'></small><noframes id='2hOX4'>

        <tfoot id='2hOX4'></tfoot>

        <i id='2hOX4'><tr id='2hOX4'><dt id='2hOX4'><q id='2hOX4'><span id='2hOX4'><b id='2hOX4'><form id='2hOX4'><ins id='2hOX4'></ins><ul id='2hOX4'></ul><sub id='2hOX4'></sub></form><legend id='2hOX4'></legend><bdo id='2hOX4'><pre id='2hOX4'><center id='2hOX4'></center></pre></bdo></b><th id='2hOX4'></th></span></q></dt></tr></i><div id='2hOX4'><tfoot id='2hOX4'></tfoot><dl id='2hOX4'><fieldset id='2hOX4'></fieldset></dl></div>
      1. 本地主机端点到 DynamoDB 本地与 Boto3

        Localhost Endpoint to DynamoDB Local with Boto3(本地主机端点到 DynamoDB 本地与 Boto3)
        <i id='1fjix'><tr id='1fjix'><dt id='1fjix'><q id='1fjix'><span id='1fjix'><b id='1fjix'><form id='1fjix'><ins id='1fjix'></ins><ul id='1fjix'></ul><sub id='1fjix'></sub></form><legend id='1fjix'></legend><bdo id='1fjix'><pre id='1fjix'><center id='1fjix'></center></pre></bdo></b><th id='1fjix'></th></span></q></dt></tr></i><div id='1fjix'><tfoot id='1fjix'></tfoot><dl id='1fjix'><fieldset id='1fjix'></fieldset></dl></div>

          <small id='1fjix'></small><noframes id='1fjix'>

            1. <legend id='1fjix'><style id='1fjix'><dir id='1fjix'><q id='1fjix'></q></dir></style></legend>
                  <tbody id='1fjix'></tbody>
                  <bdo id='1fjix'></bdo><ul id='1fjix'></ul>
                  <tfoot id='1fjix'></tfoot>
                  本文介绍了本地主机端点到 DynamoDB 本地与 Boto3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  虽然 Amazon 提供了有关如何连接到 dynamoDB local 对于 Java、PHP 和 .Net,没有描述如何使用 Python 连接到 localhost:8000.网络上的现有文档指出在 boto.dynamodb2 中使用 DynamoDBConnection 方法.layer1,但这会在使用 boto3 协议管理 dynamoDB 的实时环境和测试环境之间造成不兼容.

                  Although Amazon provides documentation regarding how to connect to dynamoDB local with Java, PHP and .Net, there is no description of how to connect to localhost:8000 using Python. Existing documentation on the web points to the use of the DynamoDBConnection method inside boto.dynamodb2.layer1, but this creates an incompatibility between live and test environments that use the boto3 protocol to manage dynamoDB.

                  在 boto3 中,您可以使用以下构造函数和设置到环境中的变量向 dynamo 发出请求:

                  In boto3, you can make a request to dynamo using the following constructor and variables set into the environment:

                  client = boto3.client('dynamodb')
                  table = client.list_tables()
                  

                  而 boto.dynamodb2.layer1 包需要您构建以下内容:

                  Whereas the boto.dynamodb2.layer1 package requires you to construct the following:

                  client = DynamoDBConnection(
                      host='localhost',
                      port=8000,
                      aws_access_key_id='anything',
                      aws_secret_access_key='anything',
                      is_secure=False)
                  table = client.list_tables()
                  

                  虽然可以创建基于本地环境确定正确构造函数的逻辑,但我对构建一组将每个构造函数视为相同的方法持谨慎态度.相反,我更愿意对所有内容都使用 boto3,并能够在环境变量中为 dynamoDB 设置端点.不幸的是,该选项目前似乎不可用.

                  Although it is possible to create logic which determines the proper constructor based upon the local environment, I am wary of building a set of methods which treat each constructor as the same. Instead, I would prefer to use boto3 for everything and to be able to set the endpoint for dynamoDB in the environmental variables. Unfortunately, that option does not appear to be currently be available.

                  有没有办法使用 boto3 来定义 dynamoDB 本地端点(像其他语言一样)?或者亚马逊是否有计划支持此功能?

                  Is there any way to use boto3 to define a dynamoDB local endpoint (like the other languages)? Or any chance that Amazon will plan to support this feature?

                  推荐答案

                  它确实支持 DynamoDB Local.您只需要设置适当的端点,例如您可以使用其他 语言 SDK

                  It does support DynamoDB Local. You just need to set the appropriate endpoint such as you can do with other language SDKs

                  以下是如何通过 DynamoDB Local 使用 boto3 的客户端和资源接口的代码片段:

                  Here is a code snippet of how you can use boto3's client and resource interface via DynamoDB Local:

                  import boto3
                  
                  # For a Boto3 client.
                  ddb = boto3.client('dynamodb', endpoint_url='http://localhost:8000')
                  response = ddb.list_tables()
                  print(response)
                  
                  # For a Boto3 service resource
                  ddb = boto3.resource('dynamodb', endpoint_url='http://localhost:8000')
                  print(list(ddb.tables.all()))
                  

                  这篇关于本地主机端点到 DynamoDB 本地与 Boto3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)

                  <legend id='hqhDS'><style id='hqhDS'><dir id='hqhDS'><q id='hqhDS'></q></dir></style></legend>
                • <i id='hqhDS'><tr id='hqhDS'><dt id='hqhDS'><q id='hqhDS'><span id='hqhDS'><b id='hqhDS'><form id='hqhDS'><ins id='hqhDS'></ins><ul id='hqhDS'></ul><sub id='hqhDS'></sub></form><legend id='hqhDS'></legend><bdo id='hqhDS'><pre id='hqhDS'><center id='hqhDS'></center></pre></bdo></b><th id='hqhDS'></th></span></q></dt></tr></i><div id='hqhDS'><tfoot id='hqhDS'></tfoot><dl id='hqhDS'><fieldset id='hqhDS'></fieldset></dl></div>

                    <bdo id='hqhDS'></bdo><ul id='hqhDS'></ul>

                        <small id='hqhDS'></small><noframes id='hqhDS'>

                      1. <tfoot id='hqhDS'></tfoot>
                          <tbody id='hqhDS'></tbody>