當前位置: 首頁>>代碼示例>>Python>>正文


Python DynamoDBConnection.connect方法代碼示例

本文整理匯總了Python中dynamo3.DynamoDBConnection.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python DynamoDBConnection.connect方法的具體用法?Python DynamoDBConnection.connect怎麽用?Python DynamoDBConnection.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dynamo3.DynamoDBConnection的用法示例。


在下文中一共展示了DynamoDBConnection.connect方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: configure

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
    def configure(cls, settings):
        kwargs = super(DynamoCache, cls).configure(settings)

        access_key = settings.get('db.access_key')
        secret_key = settings.get('db.secret_key')
        region = settings.get('db.region')
        host = settings.get('db.host')
        port = int(settings.get('db.port', 8000))
        secure = asbool(settings.get('db.secure', False))
        namespace = settings.get('db.namespace', ())

        if region is not None:
            connection = DynamoDBConnection.connect(region,
                                                    access_key=access_key,
                                                    secret_key=secret_key)
        elif host is not None:
            connection = DynamoDBConnection.connect('us-east-1',
                                                    host=host,
                                                    port=port,
                                                    is_secure=secure,
                                                    access_key=access_key,
                                                    secret_key=secret_key)
        else:
            raise ValueError("Must specify either db.region or db.host!")
        kwargs['engine'] = engine = Engine(namespace=namespace,
                                           dynamo=connection)

        engine.register(DynamoPackage, PackageSummary)
        engine.create_schema()
        return kwargs
開發者ID:Hexadite,項目名稱:pypicloud-hexadite,代碼行數:32,代碼來源:dynamo.py

示例2: configure

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
    def configure(cls, settings):
        kwargs = super(DynamoCache, cls).configure(settings)

        access_key = settings.get("db.aws_access_key_id")
        secret_key = settings.get("db.aws_secret_access_key")
        region = settings.get("db.region_name")
        host = settings.get("db.host")
        port = int(settings.get("db.port", 8000))
        secure = asbool(settings.get("db.secure", False))
        namespace = settings.get("db.namespace", ())
        graceful_reload = asbool(settings.get("db.graceful_reload", False))

        tablenames = aslist(settings.get("db.tablenames", []))
        if tablenames:
            if len(tablenames) != 2:
                raise ValueError("db.tablenames must be a 2-element list")
            DynamoPackage.meta_.name = tablenames[0]
            PackageSummary.meta_.name = tablenames[1]

        if host is not None:
            connection = DynamoDBConnection.connect(
                region,
                host=host,
                port=port,
                is_secure=secure,
                access_key=access_key,
                secret_key=secret_key,
            )
        elif region is not None:
            connection = DynamoDBConnection.connect(
                region, access_key=access_key, secret_key=secret_key
            )
        else:
            raise ValueError("Must specify either db.region_name or db.host!")
        kwargs["engine"] = engine = Engine(namespace=namespace, dynamo=connection)
        kwargs["graceful_reload"] = graceful_reload

        engine.register(DynamoPackage, PackageSummary)
        LOG.info("Checking if DynamoDB tables exist")
        engine.create_schema()
        return kwargs
開發者ID:mathcamp,項目名稱:pypicloud,代碼行數:43,代碼來源:dynamo.py

示例3: connect

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
 def connect(self, *args, **kwargs):
     """ Proxy to DynamoDBConnection.connect. """
     self.connection = DynamoDBConnection.connect(*args, **kwargs)
     self._session = kwargs.get("session")
     if self._session is None:
         self._session = botocore.session.get_session()
開發者ID:mathcamp,項目名稱:dql,代碼行數:8,代碼來源:engine.py

示例4: test_connect_to_host_without_session

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
 def test_connect_to_host_without_session(self):
     """ Can connect to a dynamo host without passing in a session """
     conn = DynamoDBConnection.connect('us-west-1', host='localhost')
     self.assertIsNotNone(conn.host)
開發者ID:normalex,項目名稱:dynamo3,代碼行數:6,代碼來源:__init__.py

示例5: test_connect_to_region_creds

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
 def test_connect_to_region_creds(self):
     """ Can connect to a dynamo region with credentials """
     conn = DynamoDBConnection.connect(
         'us-west-1', access_key='abc', secret_key='12345')
     self.assertIsNotNone(conn.host)
開發者ID:normalex,項目名稱:dynamo3,代碼行數:7,代碼來源:__init__.py

示例6: test_connect_to_region

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
 def test_connect_to_region(self):
     """ Can connect to a dynamo region """
     conn = DynamoDBConnection.connect('us-west-1')
     self.assertIsNotNone(conn.host)
開發者ID:normalex,項目名稱:dynamo3,代碼行數:6,代碼來源:__init__.py

示例7: connect

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
 def connect(self, *args, **kwargs):
     """ Connect to a specific host """
     self.dynamo = DynamoDBConnection.connect(*args, **kwargs)
開發者ID:mnpk,項目名稱:flywheel,代碼行數:5,代碼來源:engine.py

示例8: connect_to_region

# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect [as 別名]
 def connect_to_region(self, region, **kwargs):
     """ Connect to an AWS region """
     self.dynamo = DynamoDBConnection.connect(region, **kwargs)
開發者ID:mnpk,項目名稱:flywheel,代碼行數:5,代碼來源:engine.py


注:本文中的dynamo3.DynamoDBConnection.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。