store one item in database
38
def _put_one(self, item):
        ''' 
        '''
        # prepare values
        values = []
        for k, v in item.items():
            if k == '_id':
                continue
            if 'dblite_serializer' in item.fields[k]:
                serializer = item.fields[k]['dblite_serializer']
                v = serializer.dumps(v)
                if v is not None:
                    v = sqlite3.Binary(buffer(v))
            values.append(v)

        # check if Item is new => update it
        if '_id' in item:
            fieldnames = ','.join(['%s=?' % f for f in item if f != '_id'])
            values.append(item['_id'])
            SQL = 'UPDATE %s SET %s WHERE rowid=?;' % (self._table, fieldnames)
        # new Item
        else:
            fieldnames = ','.join([f for f in item if f != '_id'])
            fieldnames_template = ','.join(['?' for f in item if f != '_id'])
            SQL = 'INSERT INTO %s (%s) VALUES (%s);' % (self._table, fieldnames, fieldnames_template)

        try:
            self._cursor.execute(SQL, values)
        except sqlite3.OperationalError, err:
            raise RuntimeError('Item put() error, %s, SQL: %s, values: %s' % (err, SQL, values) )
        except sqlite3.IntegrityError:
            raise DuplicateItem('Duplicate item, %s' % item)
        self._do_autocommit()
477292
def select_one_song(songs):
        

        if len(songs) == 1:
            select_i = 0
        else:
            table = PrettyTable(['Sequence', 'Song Name', 'Artist Name'])
            for i, song in enumerate(songs, 1):
                table.add_row([i, song['name'], song['ar'][0]['name']])
            click.echo(table)

            select_i = click.prompt('Select one song', type=int, default=1)
            while select_i < 1 or select_i > len(songs):
                select_i = click.prompt('Error Select! Select Again', type=int)

        song_id, song_name = songs[select_i-1]['id'], songs[select_i-1]['name']
        song = Song(song_id, song_name)
        return song
923033
def put(self, item, block=True, timeout=None):
        """"""
        return self._queue.put(item, block, timeout)
674819
def set_item_data(self, item, filename, line_number):
        """"""
        set_item_user_text(item, '%s%s%d' % (filename, self.SEP, line_number))
749719
def put_item(omeka_item)
      self.put("items", omeka_item.data.id, omeka_item.data.to_h.to_json)
    end
919299
def save(self, items):
        '''
        
        '''
        rows = []
        indx = self.indx

        size = 0
        tick = s_common.now()

        for item in items:

            byts = s_msgpack.en(item)

            size += len(byts)

            lkey = s_common.int64en(indx)
            indx += 1

            rows.append((lkey, byts))

        self.slab.putmulti(rows, append=True, db=self.db)
        took = s_common.now() - tick

        origindx = self.indx
        self.indx = indx
        return {'indx': indx, 'size': size, 'count': len(items), 'time': tick, 'took': took}

        return origindx
1153893
def find_one(self, cls, id):
        """"""
        try:
            db_result = self.get_class_table(cls).lookup(id)
        except ItemNotFound:
            # according to docs, this shouldn't be required, but it IS
            db_result = None

        if not db_result:
            return None

        obj = cls.from_data(db_result['value'])
        return obj
923625
def store_relation(self, src, name, dst):
        '''  '''
        self.__require_string__(name)
        #print('storing relation', src, name, dst)
        # make sure both items are stored
        self.store_item(src).link(name, self.store_item(dst))
1235394
function saveBook( $blog_id, array $item ) {

		/** @var $wpdb \wpdb */
		global $wpdb;

		unset( $item['users_id'], $item['blogs_id'], $item['deleted'] ); // Don't allow spoofing

		$data = [
			'users_id' => $this->userId,
			'blogs_id' => $blog_id,
			'deleted' => 0,
		];
		$format = [
			'users_id' => $this->dbColumns['users_id'],
			'blogs_id' => $this->dbColumns['blogs_id'],
			'deleted' => $this->dbColumns['deleted'],
		];

		foreach ( $item as $key => $val ) {
			if ( isset( $this->dbColumns[ $key ] ) ) {
				$data[ $key ] = $val;
				$format[ $key ] = $this->dbColumns[ $key ];
			}
		}

		// INSERT ... ON DUPLICATE KEY UPDATE
		// @see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

		$args = [];
		$sql = "INSERT INTO {$this->dbTable} ( ";
		foreach ( $data as $key => $val ) {
			$sql .= "`$key`, ";
		}
		$sql = rtrim( $sql, ', ' ) . ' ) VALUES ( ';

		foreach ( $format as $key => $val ) {
			$sql .= $val . ', ';
			$args[] = $data[ $key ];
		}
		$sql = rtrim( $sql, ', ' ) . ' ) ON DUPLICATE KEY UPDATE ';

		$i = 0;
		foreach ( $data as $key => $val ) {
			if ( 'users_id' === $key || 'blogs_id' === $key ) {
				continue;
			}
			$sql .= "`$key` = {$format[$key]}, ";
			$args[] = $val;
			++$i;
		}
		$sql = rtrim( $sql, ', ' );
		if ( ! $i ) {
			$sql .= ' users_id = users_id '; // Do nothing
		}

		return $wpdb->query( $wpdb->prepare( $sql, $args ) ); // @codingStandardsIgnoreLine
	}
1035946
def save_item(self, item_form, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.ResourceAdminSession.update_resource
        if item_form.is_for_update():
            return self.update_item(item_form, *args, **kwargs)
        else:
            return self.create_item(item_form, *args, **kwargs)
941234
def store_attribute(self, key, value):
        """"""
        if key == 'summary' or key == 'filename' or key == 'previous':
            return
        attr = key.replace('-', '_')
        if key.endswith('-time'):
            value = int(value)
        setattr(self, attr, value)
964886
def store(self, key, pk, value):
        

        self.connection.zadd(key, value, pk)
1079604
def store(bank, key, data):
    '''
    
    '''
    _init_client()
    data = __context__['serial'].dumps(data)
    query = b"REPLACE INTO {0} (bank, etcd_key, data) values('{1}', '{2}', " \
        b"'{3}')".format(_table_name,
                         bank,
                         key,
                         data)

    cur, cnt = run_query(client, query)
    cur.close()
    if cnt not in (1, 2):
        raise SaltCacheError(
            'Error storing {0} {1} returned {2}'.format(bank, key, cnt)
        )
320310
def put(self, item):
        '''
        
        '''
        if self.isfini:
            return False

        self.fifo.append(item)

        if len(self.fifo) == 1:
            self.event.set()

        return True
1095931
def set(self, key, value):
        """"""
        self.store[key]=value
        return self.store
1347616
def one_item(self, item, detach:bool=False, denorm:bool=False, cpu:bool=False):
        ""
        ds = self.single_ds
        with ds.set_item(item):
            return self.one_batch(ds_type=DatasetType.Single, detach=detach, denorm=denorm, cpu=cpu)
473254
def store_many(self, items):
        
        with self.walrus.atomic():
            for item in items:
                self.store(*item)