Inserts a record into database, table "table", using the list of
        fieldnames and the list of records (each a list of values).
        Returns number of rows affected.
17219
def insert_multiple_records(self,
                                table: str,
                                fields: Sequence[str],
                                records: Sequence[Sequence[Any]]) -> int:
        """"""
        self.ensure_db_open()
        sql = self.localize_sql(get_sql_insert(table, fields,
                                               self.get_delims()))
        log.debug("About to insert multiple records with SQL template: " + sql)
        try:
            cursor = self.db.cursor()
            debug_sql(sql, records)
            cursor.executemany(sql, records)
            # ... binds the placeholders (?, %s) to values in the process
            # http://www.python.org/dev/peps/pep-0249/
            log.debug("Records inserted.")
            return cursor.rowcount
        except:  # nopep8
            log.exception("insert_multiple_records: Failed to insert records.")
            raise
630655
def _construct_inserts(self, record, new_columns, rename_columns, retype_columns, resize_columns):

        '''  '''

        insert_kwargs = {}

        for key, value in new_columns.items():

        # retrieve value for key (or from old key name)
            if key in rename_columns.keys():
                record_value = getattr(record, rename_columns[key], None)
            else:
                record_value = getattr(record, key, None)

        # attempt to convert datatype
            if record_value:
                if key in retype_columns.keys():
                    try:
                        old_list = False
                        if isinstance(record_value, bytes):
                            record_value = pickle.loads(record_value)
                            old_list = True
                        if retype_columns[key] == 'boolean':
                            record_value = bool(record_value)
                        elif retype_columns[key] == 'string':
                            if old_list:
                                record_value = ','.join(record_value)
                            else:
                                record_value = str(record_value)
                        elif retype_columns[key] == 'integer':
                            if old_list:
                                record_value = int(record_value[0])
                            else:
                                record_value = int(record_value)
                        elif retype_columns[key] == 'float':
                            if old_list:
                                record_value = int(record_value[0])
                            else:
                                record_value = float(record_value)
                        elif retype_columns[key] == 'list':
                            if isinstance(record_value, str):
                                record_value = pickle.dumps(record_value.split(','))
                            else:
                                record_value = pickle.dumps([record_value])
                    except:
                        record_value = None
        
        # attempt to resize string data 
                if key in resize_columns.keys():
                    max_length = resize_columns[key]
                    try:
                        if len(record_value) > max_length:
                            record_value = record_value[0:max_length]
                    except:
                        record_value = None

                insert_kwargs[key] = record_value

        return insert_kwargs
608200
def insert_all(db, schema_name, table_name, columns, items):
    
    table = '{0}.{1}'.format(schema_name, table_name) if schema_name else table_name
    columns_list = ', '.join(columns)
    values_list = ', '.join(['?'] * len(columns))
    query = 'INSERT INTO {table} ({columns}) VALUES ({values})'.format(
        table=table, columns=columns_list, values=values_list)
    for item in items:
        values = [getattr(item, col) for col in columns]
        db.execute(query, values)
658514
def compile_insert(self, query, values):
        
        # Essentially we will force every insert to be treated as a batch insert which
        # simply makes creating the SQL easier for us since we can utilize the same
        # basic routine regardless of an amount of records given to us to insert.
        table = self.wrap_table(query.from__)

        if not isinstance(values, list):
            values = [values]

        columns = self.columnize(values[0].keys())

        # We need to build a list of parameter place-holders of values that are bound
        # to the query. Each insert should have the exact same amount of parameter
        # bindings so we can just go off the first list of values in this array.
        parameters = self.parameterize(values[0].values())

        value = ['(%s)' % parameters] * len(values)

        parameters = ', '.join(value)

        return 'INSERT INTO %s (%s) VALUES %s' % (table, columns, parameters)
750818
public int insert(Entity record) throws SQLException {
		Connection conn = null;
		try {
			conn = this.getConnection();
			return runner.insert(conn, record);
		} catch (SQLException e) {
			throw e;
		} finally {
			this.closeConnection(conn);
		}
	}
315309
def insertDict(self, tblname, d, fields = None):
		''''''
		
		if fields == None:
			fields = sorted(d.keys())
		values = None
		try:
			SQL = 'INSERT INTO %s (%s) VALUES (%s)' % (tblname, join(fields, ", "), join(['%s' for x in range(len(fields))], ','))
			values = tuple([d[k] for k in fields])
	 		self.locked_execute(SQL, parameters = values)
		except Exception, e:
			if SQL and values:
				sys.stderr.write("\nSQL execution error in query '%s' %% %s at %s:" % (SQL, values, datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
			sys.stderr.write("\nError: '%s'.\n" % (str(e)))
			sys.stderr.flush()
			raise Exception("Error occurred during database insertion: '%s'." % str(e))
279084
def insert(self, model_instances, batch_size=1000):
        '''
        
        '''
        from six import next
        from io import BytesIO
        i = iter(model_instances)
        try:
            first_instance = next(i)
        except StopIteration:
            return  # model_instances is empty
        model_class = first_instance.__class__

        if first_instance.is_read_only() or first_instance.is_system_model():
            raise DatabaseException("You can't insert into read only and system tables")

        fields_list = ','.join(
            ['`%s`' % name for name in first_instance.fields(writable=True)])

        def gen():
            buf = BytesIO()
            query = 'INSERT INTO $table (%s) FORMAT TabSeparated\n' % fields_list
            buf.write(self._substitute(query, model_class).encode('utf-8'))
            first_instance.set_database(self)
            buf.write(first_instance.to_tsv(include_readonly=False).encode('utf-8'))
            buf.write('\n'.encode('utf-8'))
            # Collect lines in batches of batch_size
            lines = 2
            for instance in i:
                instance.set_database(self)
                buf.write(instance.to_tsv(include_readonly=False).encode('utf-8'))
                buf.write('\n'.encode('utf-8'))
                lines += 1
                if lines >= batch_size:
                    # Return the current batch of lines
                    yield buf.getvalue()
                    # Start a new batch
                    buf = BytesIO()
                    lines = 0
            # Return any remaining lines in partial batch
            if lines:
                yield buf.getvalue()
        self._send(gen())
1122858
def load_table(self, table, rows, colnames=None, limit=None):
        

        conn = self.engine.raw_connection()
        cur = conn.cursor()

        colnames = colnames or next(rows)

        cmd = 'INSERT INTO {table} ({colnames}) VALUES ({placeholders})'.format(
            table=self.tables[table],
            colnames=', '.join(colnames),
            placeholders=', '.join([self.placeholder] * len(colnames)))

        cur.executemany(cmd, itertools.islice(rows, limit))
        conn.commit()
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;
    }
38241
def insert(self, table, columns, rows):
        
        cursor = self.conn.cursor()
        if len(rows):
            templ, _args = match('INSERT INTO ?s (?S) VALUES (?X)',
                                 table, columns, rows[0])
            cursor.executemany(templ, rows)
        return cursor
378728
def table(self, name: str):
        
        if self._check_db() == False:
            return
        try:
            res = self.getall(name)
        except Exception as e:
            self.err(e, self.table, "Can not get records from database")
            return
        if res is None:
            self.warning("Table", name, "does not contain any record")
            return
        num = len(res)
        self.info(num, "rows")
        self.info("Fields:", ", ".join(list(res)))
1037083
def insert(self, row):
        
        self._check_dropped()
        res = self.engine.execute(self.table.insert(row))
        if len(res.inserted_primary_key) > 0:
            return res.inserted_primary_key[0]
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")
314478
public int[] insert(Connection conn, Collection<Entity> records) throws SQLException {
		return insert(conn, records.toArray(new Entity[records.size()]));
	}
684207
def put(self, _name, **values):
        
        try:
            sql = self.sqles[_name]
            data = sql['data']
            if sql['positional']:
                d = [values[k] for k, v in sql['fields'].items()]
            else:
                d = {v:values[k] for k, v in sql['fields'].items()}
            data.append(d)
            if self.size and len(data) >= self.size:
                do_(sql['raw_sql'], args=data)
                sql['data'] = []
        except:
            if self.transcation:
                Rollback(self.engine)
            raise
85515
def insert_record_by_dict(self,
                              table: str,
                              valuedict: Dict[str, Any]) -> Optional[int]:
        """"""
        if not valuedict:
            return None
        n = len(valuedict)
        fields = []
        args = []
        for f, v in valuedict.items():
            fields.append(self.delimit(f))
            args.append(v)
        query = """
            INSERT INTO {table}
                ({fields})
                VALUES ({placeholders})
        """.format(
            table=table,
            fields=",".join(fields),
            placeholders=",".join(["?"]*n)
        )
        query = self.localize_sql(query)
        log.debug("About to insert_record_by_dict with SQL template: " + query)
        try:
            cursor = self.db.cursor()
            debug_sql(query, args)
            cursor.execute(query, args)
            new_pk = get_pk_of_last_insert(cursor)
            log.debug("Record inserted.")
            return new_pk
        except:  # nopep8
            log.exception("insert_record_by_dict: Failed to insert record.")
            raise
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