Insert new record.
500700
def add(data_dic):
        '''
        
        '''
        uid = data_dic['uid']
        TabLog.create(
            uid=uid,
            current_url=data_dic['url'],
            refer_url=data_dic['refer'],
            user_id=data_dic['user_id'],
            time_create=data_dic['timein'],
            time_out=data_dic['timeOut'],
            time=data_dic['timeon']
        )

        return uid
151267
def _create_record(attribute_names = self.attribute_names)
      attribute_names = attributes_for_create(attribute_names)

      new_id = self.class._insert_record(
        attributes_with_values(attribute_names)
      )

      self.id ||= new_id if @primary_key

      @new_record = false

      yield(self) if block_given?

      id
    end
921870
public void insert(EventRecord er) {
    SerializedRecord sr = new SerializedRecord(er);
    try {
      Anonymizer.anonymize(sr);
    } catch (Exception e) {
      e.printStackTrace();
    }
    append(sr);
  }
984477
def insert(self):
        """"""
        from mongoframes.queries import to_refs

        # Send insert signal
        signal('insert').send(self.__class__, frames=[self])

        # Prepare the document to be inserted
        document = to_refs(self._document)

        # Insert the document and update the Id
        self._id = self.get_collection().insert_one(document).inserted_id

        # Send inserted signal
        signal('inserted').send(self.__class__, frames=[self])
935415
def insert(self):
    """"""
    if not self.curs:
      raise LIGOLwDBError, "Database connection not initalized"
    if len(self.table) == 0:
      raise LIGOLwDBError, 'attempt to insert empty table'
    for tab in self.table.keys():
      # find and add any missing unique ids
      generate = []
      missingcols = [k for k in self.ldb.uniqueids[tab] 
        if k not in self.table[tab]['column']]
      for m in missingcols:
        generate.append(',BLOB(GENERATE_UNIQUE())')
        self.table[tab]['orderedcol'].append(m)
      # and construct the sql query
      self.table[tab]['query'] = ' '.join( 
        ['INSERT INTO', tab, '(', ','.join(self.table[tab]['orderedcol']), 
        ') VALUES (', ','.join(['?' for x in self.table[tab]['column']]) , 
        ''.join(generate), ')'])
    for tabtup in self.ldb.tables:
      tab = tabtup[0].lower()
      try:
        try: 
          self.curs.executemany(self.table[tab]['query'],
            self.table[tab]['stream'])
          rowcount = self.curs.rowcount
        except DB2.Error, e:
          self.curs.execute('rollback')
          msg = e[2] 
          msg += self.xml() + '\n' 
          msg += str(self.table[tab]['query']) + '\n' 
          msg += str(self.table[tab]['stream']) + '\n'
          raise LIGOLwDBError, msg
        except DB2.Warning, e:
          self.curs.execute('rollback')
          raise LIGOLwDBError, e[2]
        #except Exception, e:
        #  self.curs.execute('rollback')
        #  raise LIGOLwDBError, e[2]
      except KeyError:
        pass
    self.curs.execute('commit')
    return rowcount
522363
def insert(self, table, columns, values, execute=True):
        """"""
        # TODO: Cant accept lists?
        # Concatenate statement
        cols, vals = get_col_val_str(columns)
        statement = "INSERT INTO {0} ({1}) VALUES ({2})".format(wrap(table), cols, vals)

        # Execute statement
        if execute:
            self._cursor.execute(statement, values)
            self._commit()
            self._printer('\tMySQL row successfully inserted into {0}'.format(table))

        # Only return statement
        else:
            return statement
439109
def insert(self, schema, fields, **kwargs):
        
        r = 0

        with self.connection(**kwargs) as connection:
            kwargs['connection'] = connection
            try:
                with self.transaction(**kwargs):
                    r = self._insert(schema, fields, **kwargs)

            except Exception as e:
                exc_info = sys.exc_info()
                if self.handle_error(schema, e, **kwargs):
                    r = self._insert(schema, fields, **kwargs)
                else:
                    self.raise_error(e, exc_info)

        return r
1330106
def new_record(self, key, value):
    
    new_record = self.get('new_record', {})
    ids = self.get('ids', [])

    for value in force_list(value):
        for id_ in force_list(value.get('a')):
            ids.append({
                'schema': 'SPIRES',
                'value': id_,
            })

        new_recid = force_single_element(value.get('d', ''))
        if new_recid:
            new_record = get_record_ref(new_recid, 'authors')

    self['ids'] = ids
    return new_record
40817
def db_insert_record(self, table_name, columns):
        
        bindings = ('?,' * len(columns)).strip(',')
        values = [None] * len(columns)
        sql = 'INSERT INTO {} ({}) VALUES ({})'.format(table_name, ', '.join(columns), bindings)
        cur = self.db_conn.cursor()
        cur.execute(sql, values)
1062812
public void insertRecord(
      Object recordBase, long recordOffset, int length, long prefix, boolean prefixIsNull)
    throws IOException {

    assert(inMemSorter != null);
    if (inMemSorter.numRecords() >= numElementsForSpillThreshold) {
      logger.info("Spilling data because number of spilledRecords crossed the threshold " +
        numElementsForSpillThreshold);
      spill();
    }

    growPointerArrayIfNecessary();
    int uaoSize = UnsafeAlignedOffset.getUaoSize();
    // Need 4 or 8 bytes to store the record length.
    final int required = length + uaoSize;
    acquireNewPageIfNecessary(required);

    final Object base = currentPage.getBaseObject();
    final long recordAddress = taskMemoryManager.encodePageNumberAndOffset(currentPage, pageCursor);
    UnsafeAlignedOffset.putSize(base, pageCursor, length);
    pageCursor += uaoSize;
    Platform.copyMemory(recordBase, recordOffset, base, pageCursor, length);
    pageCursor += length;
    inMemSorter.insertRecord(recordAddress, prefix, prefixIsNull);
  }
1338088
def insert(self, table, records, create_cols=False, dtypes=None):
        
        if self._check_db() is False:
            return
        try:
            table = self.db[table]
        except Exception as e:
            self.err(e, "Can not find table " + table)
        t = type(records)
        if t == dict:
            func = table.insert
        elif t == list:
            func = table.insert_many
        else:
            msg = "Rows datatype " + \
                str(t) + " not valid: use a list or a dictionary"
            self.err(msg)
        if create_cols is True:
            try:
                func(records, ensure=True, types=dtypes)
            except Exception as e:
                self.err(e, "Can not insert create columns and insert data")
            return
        else:
            try:
                func(records, types=dtypes)
            except Exception as e:
                self.err(e, "Can not insert data")
            return
        self.ok("Rows inserted in the database")
27553
def add(self, instance):
        '''
        
        '''

        table = instance.__class__.__name__.lower()
        keys = ", ".join(vars(instance).keys())
        values = tuple(vars(instance).values())

        SQL = """INSERT INTO %s (%s) VALUES(""" % (table, keys)
        SQL += """ "%s",""" * len(values) % (values)
        SQL = SQL[:-1] + ")"

        if self.DEBUG: print(SQL)

        with Session(self.settings) as conn:
            try:
                c = conn.cursor()
                c.execute(SQL)
                conn.commit()
                return True
            except mysql.Error as e:
                if e.errno==1062:
                    print("Already saved to the database")
                    return True
                elif e.errno == 1146:
                    # Table does not exist
                    return True
                else:
                    raise e

                return True
993042
def insert_after(self, key, new_item, instance=0):
        """"""
        self._insert_item(key, new_item, instance, True)
1150731
protected int insertRecord(Connection connection, String hash)
            throws SQLException {
        int id = -1;
        PreparedStatement ps = setObjects(connection, Query.INSERT_RECORD, hash);
        ps.execute();
        ResultSet rs = ps.getGeneratedKeys();
        try {
            while (rs.next()) {
                id = rs.getInt(1);
                break;
            }
        } finally {
            rs.close();
            ps.close();
        }

        return id;
    }
1088362
def add(self, key):
        '''
        
        '''
        encodedKey = json.dumps(key)
        with self.connect() as conn:
            with doTransaction(conn):
                sql = 'INSERT IGNORE INTO ' + self.table + ' (name) VALUES (%s)'
                return insertSQL(conn, sql, args=[encodedKey])
753630
def update(self,records,**kw):
        """"""
        # ignore unknown fields
        kw = dict([(k,v) for (k,v) in kw.iteritems() if k in self.fields])
        if isinstance(records,dict):
            records = [ records ]
        # update indices
        for indx in set(self.indices.keys()) & set (kw.keys()):
            for record in records:
                if record[indx] == kw[indx]:
                    continue
                _id = record["__id__"]
                # remove id for the old value
                old_pos = bisect.bisect(self.indices[indx][record[indx]],_id)-1
                del self.indices[indx][record[indx]][old_pos]
                if not self.indices[indx][record[indx]]:
                    del self.indices[indx][record[indx]]
                # insert new value
                bisect.insort(self.indices[indx].setdefault(kw[indx],[]),_id)
        for record in records:
            # update record values
            record.update(kw)
            # increment version number
            record["__version__"] += 1
651952
def setRecord(self, record):
        
        self._record = record
        if record is not None:
            self.loadValues(record.recordValues(autoInflate=True))
        else:
            self.loadValues({})