本文整理匯總了Python中dynamo3.DynamoDBConnection.connect_to_host方法的典型用法代碼示例。如果您正苦於以下問題:Python DynamoDBConnection.connect_to_host方法的具體用法?Python DynamoDBConnection.connect_to_host怎麽用?Python DynamoDBConnection.connect_to_host使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dynamo3.DynamoDBConnection
的用法示例。
在下文中一共展示了DynamoDBConnection.connect_to_host方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: initialize
# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect_to_host [as 別名]
def initialize(self, region='us-west-1', host='localhost', port=8000,
access_key=None, secret_key=None, config_dir=None):
""" Set up the repl for execution. """
# Tab-complete names with a '-' in them
import readline
delims = set(readline.get_completer_delims())
if '-' in delims:
delims.remove('-')
readline.set_completer_delims(''.join(delims))
self._conf_dir = (config_dir or
os.path.join(os.environ.get('HOME', '.'), '.config'))
self.session = botocore.session.get_session()
if access_key:
self.session.set_credentials(access_key, secret_key)
if region == 'local':
conn = DynamoDBConnection.connect_to_host(host, port,
session=self.session)
else:
conn = DynamoDBConnection.connect_to_region(region, self.session)
self.engine = FragmentEngine(conn)
conf = self.load_config()
display_name = conf.get('display')
if display_name is not None:
self.display = DISPLAYS[display_name]
else:
self.display = get_default_display()
self.formatter = SmartFormat(pagesize=conf.get('pagesize', 1000),
width=conf.get('width', 80))
for line in conf.get('autorun', []):
six.exec_(line, self.engine.scope)
示例2: do_use
# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect_to_host [as 別名]
def do_use(self, region, host='localhost', port=8000):
"""
Switch the AWS region
You may also specify 'use local host=localhost port=8000' to use the
DynamoDB Local service
"""
if region == 'local':
conn = DynamoDBConnection.connect_to_host(
host, port, session=self.session)
else:
conn = DynamoDBConnection.connect_to_region(region, self.session)
self.engine.connection = conn
示例3: test_connect_to_host_without_session_old
# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect_to_host [as 別名]
def test_connect_to_host_without_session_old(self):
""" Can connect to a dynamo host without passing in a session """
conn = DynamoDBConnection.connect_to_host(access_key='abc',
secret_key='12345')
self.assertIsNotNone(conn.host)
示例4: connect_to_host
# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect_to_host [as 別名]
def connect_to_host(self, **kwargs):
""" Connect to a specific host """
self.dynamo = DynamoDBConnection.connect_to_host(**kwargs)
示例5: connect_to_host
# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect_to_host [as 別名]
def connect_to_host(self, *args, **kwargs):
""" Connect the engine to a specific host """
self.connection = DynamoDBConnection.connect_to_host(*args, **kwargs)
示例6: test_connect_to_host_without_session
# 需要導入模塊: from dynamo3 import DynamoDBConnection [as 別名]
# 或者: from dynamo3.DynamoDBConnection import connect_to_host [as 別名]
def test_connect_to_host_without_session(self):
""" Can connect to a dynamo host without passing in a session """
conn = DynamoDBConnection.connect_to_host()
self.assertIsNotNone(conn.host)