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


Python Item.save方法代码示例

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


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

示例1: Item

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
class Item(ItemEngine):

    def __init__(self, collection, raw_item):
        ItemEngine.__init__(self, collection, raw_item)
        self.__item = raw_item

    @property
    def ddb_item(self):
        return self.__item

    def update(self, patch, context, updates):
        if patch:
            for k, v in iteritems(updates):
                self.__item[k] = v
            self.__item.partial_save()
        else:
            if context is None:
                self.__item = BotoItem(self.__item.table, updates)
                self.__item.save(True)
            else:
                context.put_item(self.__table, updates)

    def delete(self, index, context):
        if context is None:
            self.__item.delete()
        else:
            context.delete_item(
                self.__table,
                **(index.make_key_dict_from_dict(self.get_dict()))
            )

    def get_dict(self):
        return self.__item._data
开发者ID:xica,项目名称:hieratic-dynamodb,代码行数:35,代码来源:__init__.py

示例2: deprecated__handle_truth

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
 def deprecated__handle_truth( self, rs ):
     if self._mask is None:
         self._mask = rs.get_mask()
     rs.set_mask(self._mask)
     accuracy = rs.accuracy()
     with tempfile.SpooledTemporaryFile() as temp:
         np.save(temp, accuracy)
         temp.seek(0)
         conn = boto.connect_s3(  )
         bucket = conn.create_bucket( self.s3_results )
         k = Key(bucket)
         m = hashlib.md5()
         m.update(accuracy)
         md5 =  m.hexdigest()
         k.key = md5
         k.set_contents_from_file( temp )
     run_id = rs.get_run_id()
     try:
         item = Item( self.truth_table, {'run_id':run_id,
                 'strain_id': rs.spec_string} )
         item['accuracy_file'] = md5
         item['result_files'] =  base64.b64encode( json.dumps( 
             rs.get_result_files() ) )
         item['bucket'] = self.s3_results
         item['timestamp'] = datetime.datetime.utcnow().strftime('%Y.%m.%d-%H:%M:%S')
         item.save()
     except ConditionalCheckFailedException as ccfe:
         print "*"*20
         print ccfe
         if rs is not None:
             print  {'run_id':run_id,'strain_id': rs.spec_string}
             print rs.get_result_files()
开发者ID:JohnCEarls,项目名称:DataDirac,代码行数:34,代码来源:aggregate.py

示例3: main

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
def main(args):
  conn=dynaconnect(args)
  tableName=args.table

  try:
    conn.describe_table(tableName)
  except boto.exception.JSONResponseError as details:
    if (details.error_code != "ResourceNotFoundException"):
      error("Error when connecting to DynamodDB",details.message)
    
    sys.stdout.write("Table does not exist, creating it")
    sys.stdout.flush()
    
    table = Table.create(tableName, schema=[ HashKey('name') ], global_indexes=[GlobalAllIndex('StacksByType', parts=[HashKey('type')])], connection=conn)

    while (table.describe()["Table"]["TableStatus"]!="ACTIVE"):
      time.sleep(1)
      sys.stdout.write('.')
      sys.stdout.flush()
    print("")
  else:
    table = Table(tableName,connection=conn)

  parameters = dict([x.strip() for x in line.strip().split("=")] for line in open(args.prop_file))
  additionals = dict([x.strip() for x in k.strip().split("=")] for k in args.key)

  dynamodata={'type':args.type, 'name':args.name, 'config':parameters}
  dynamodata.update(additionals)
  item=Item(table,data=dynamodata)

  item.save(overwrite=True)
开发者ID:Shaiou,项目名称:demo,代码行数:33,代码来源:setparams.py

示例4: put

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
    def put(self, key, value):
        '''Stores the object.'''
        table = self._table(key)

        value = self._wrap(table, key, value)
        item = Item(table, data=value)
        item.save(overwrite=True)
开发者ID:datastore,项目名称:datastore.dynamo,代码行数:9,代码来源:__init__.py

示例5: add_to_db

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
    def add_to_db(self):
        items_table = Table('items')

        for product in self.viable_products:
            temp_item = Item(items_table, data={
                'type':'iphone',
                'title':product[0],
                'itemId':product[1],
                'viewItemURL':product[2],
                'sellerUserName':product[3],
                'positiveFeedbackPercent':product[4],
                'feedbackRatingStar':product[5],
                'conditionId':product[6],
                'listingType':product[7],
                'currentPrice':product[8],
                'bidCount':product[9],
                'timeLeft':product[10],
                'endTime':product[11],
                'carrier':product[12],
                'storage':product[13],
                'model':product[14],
                'color':product[15],
                'pmresult':product[16],
            })

            temp_item.save(overwrite=True)

        print 'all set'
开发者ID:biddyweb,项目名称:Crimson-Bids,代码行数:30,代码来源:parse_results.py

示例6: create_tables

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
    def create_tables(self):
        '''
        () -> None

        Permite crear todas las tablas necesarias para el entorno de pruebas.
        Las tablas creadas seran llenadas con datos de prueba que se encuentran
        en el archivo test_data.json.
        '''

        #Creacion de las tablas para los test
        super(dbTablesTest, self).create_tables()

        import os
        from commons import jsondecoder

        #cargar los datos de prueba del archivo test_data.json
        path_file = os.path.abspath(self.config['DB_TEST_DATA_PATH'])
        json_data = open(path_file).read()
        data = jsondecoder(json_data)

        #guardar los datos contenidos en el archivo json en la base de datos.
        for key, value in data.items():
            table = self.tables[key]
            for item in value:
                if key == 'tbl_timeline':
                    if 'skills' in item:
                        item['skills'] = set(item['skills'])
                    if 'win_answers' in item:
                        item['win_answers'] = set(item['win_answers'])
                item = Item(table, data=item)
                item.save()
开发者ID:oxfishapp,项目名称:RESTful,代码行数:33,代码来源:dynamoDB.py

示例7: create_or_update_user

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
    def create_or_update_user(self, datos_twitter, access_token, token_secret):
        '''(dict or Item) -> bool

        crea un nuevo usaurio o lo actualiza si ya existe.
        '''

        user = self.get_item(key_twitter=datos_twitter['key_twitter'])

        token = generate_token(hash_key=datos_twitter['key_twitter'],
                               access_token=access_token,
                               token_secret=token_secret)

        #Valida si el usuario ya se encuentra registrado en la base de datos.
        #si no existe se crea y si existe se actualiza.
        if not user:
            datos_twitter['registered'] = timeUTCCreate()
            datos_twitter['key_user'] = hashCreate()
            datos_twitter['token_user'] = token
            user = Item(table_user, datos_twitter)
        else:
            user._data['nickname'] = datos_twitter['nickname']
            user._data['name'] = datos_twitter['name']
            user._data['link_image'] = datos_twitter['link_image']
            user._data['token_user'] = token
        user.save()
        return user._data
开发者ID:oxfishapp,项目名称:RESTful,代码行数:28,代码来源:dynamoDBqueries.py

示例8: save_partition

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
def save_partition(part):

    for record in part:
        item = Item(
            out_table,
            data={"airport": record[0][0], "carrier": record[0][1], "mean_delay": int(record[1][0] / record[1][1])},
        )
        item.save(overwrite=True)
开发者ID:gmcorral,项目名称:cloud-capstone,代码行数:10,代码来源:g2e1.py

示例9: save_partition

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
def save_partition(part):

    for record in part:
        item = Item(out_table, data={
            "origin": record[0][0],
            "destination": record[0][1],
            "mean_delay": int(record[1][0] / record[1][1])
        })
        item.save(overwrite=True)
开发者ID:gmcorral,项目名称:cloud-capstone,代码行数:11,代码来源:g2e4.py

示例10: get_state

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
def get_state(table, project):
	try:
		return table.get_item(project=project, consistent=True)
	except ItemNotFound:
		state = Item(table, data={
			'project': project,
			'state': 'idle',
		})
		state.save()
开发者ID:goabout,项目名称:docker-serialized-ansible,代码行数:11,代码来源:serialize.py

示例11: update

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
 def update(cls, form_id, user_id, answer_json):
     answers_table = Table("answers")
     questions_with_answers = answer_json["questions"]
     for question_with_answer in questions_with_answers:
         item = Item(
             answers_table,
             data={
                 "form_question_id": cls.form_question_id(form_id, question_with_answer["question_id"]),
                 "answer": question_with_answer["answer"],
                 "user_id": user_id,
             },
         )
         item.save(overwrite=True)
开发者ID:rgan,项目名称:formbuilder_backend,代码行数:15,代码来源:answer.py

示例12: add_new_keg

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
def add_new_keg(tap, cost, volume, abv, beer_name):
    remove_current_keg(tap)
    new_keg = Item(kegs, data={
                'tap': str(tap),
                'start_timestamp': str(long(time.time())),
                'finish_timestamp': str(-1),
                'cost': str(cost),
                'volume': str(volume),
                'abv': str(abv),
                'beer_name': str(beer_name),
                'volume_remaining': str(volume)
                })
    new_keg.save()
开发者ID:drunkenrobotengineering,项目名称:kegerator,代码行数:15,代码来源:dynamo_calls.py

示例13: _create_post

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
    def _create_post(self, data):
        '''(item) -> NoneType

        Funcion de apoyo, crea un item en la tabla timeline

        '''
        data['key_post'] = hashCreate()
        data['key_timeline_post'] = timeUTCCreate()
        post = Item(table_timeline, data)
        post.save()
        if not data.get('key_post_original'):
            cskill = Skill()
            cskill.post_skills_post(list(data['skills']), data['key_post'])
开发者ID:oxfishapp,项目名称:RESTful,代码行数:15,代码来源:dynamoDBqueries.py

示例14: putRecord

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
def putRecord(fid, filename, desc, keysrc, keythb):
    """ Adds a new item to the DynamoDB table."""
    uid = "unique ID"
    timestamp = "timestamp" 
    new_item = Item(get_table(), data={
        'owner': 'Carlos',
        'uid': fid,
        'name': filename,
        'description': desc,
        'timestamp': datetime.today().strftime('%Y%m%d-%H%M%S-%f'),
        'source': keysrc,
        'thumbnail': keythb
    })
    new_item.save()
开发者ID:AWSLuxGroup,项目名称:workshop1-python,代码行数:16,代码来源:application.py

示例15: register_fob

# 需要导入模块: from boto.dynamodb2.items import Item [as 别名]
# 或者: from boto.dynamodb2.items.Item import save [as 别名]
def register_fob(fob_id, drinker_id):
    drinker = get_drinker(drinker_id)
    if not drinker:
        return False
    fob = get_fob(fob_id)
    if not fob:
        fob = Item(fobs, data={
                'fob_id': str(fob_id),
                'drinker_id': str(drinker_id)
                })
    fob['drinker_id'] = (drinker_id)
    fob['fob_id'] = str(fob_id)
    fob.save()
    return True
开发者ID:drunkenrobotengineering,项目名称:kegerator,代码行数:16,代码来源:dynamo_calls.py


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