47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.6 KiB
1.6 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| db_insert_batch | function | go | infra | 1.0.0 | impure | func DBInsertBatch(db *sql.DB, table string, columns []string, rows [][]any) (int64, error) | Inserta multiples filas en una transaccion usando prepared statement. Retorna el total de filas afectadas. Mas eficiente que llamar DBInsertRow en un loop. |
|
|
false | error_go_core |
|
|
numero total de filas insertadas exitosamente | false | functions/infra/db_insert_batch.go |
Ejemplo
cols := []string{"name", "score", "ts"}
rows := [][]any{
{"Alice", 95.5, 1700000000},
{"Bob", 87.2, 1700000001},
{"Carol", 91.0, 1700000002},
}
n, err := DBInsertBatch(db, "results", cols, rows)
if err != nil {
return err
}
fmt.Printf("insertadas: %d filas\n", n)
Notas
Usa tx.Prepare() + stmt.Exec() en un loop dentro de una transaccion. El rollback es automatico si alguna fila falla. Valida tabla y columnas con regex. Cada fila debe tener exactamente len(columns) valores — retorna error descriptivo si no coincide.