47235e702c
Funciones Go con interfaz unificada para operaciones DB: open, close, create_table, exec, query, insert_row, insert_batch. Openers específicos por engine. Tipo DBConfig para configuración común. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
980 B
980 B
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, 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 | tested | tests | test_file_path | file_path | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| db_exec | function | go | infra | 1.0.0 | impure | func DBExec(db *sql.DB, query string, args ...any) (int64, error) | Ejecuta un statement no-SELECT (INSERT, UPDATE, DELETE, DDL) y retorna el numero de filas afectadas. |
|
false | error_go_core |
|
false | functions/infra/db_exec.go |
Ejemplo
n, err := DBExec(db, "UPDATE users SET active = ? WHERE last_login < ?", false, cutoff)
if err != nil {
return err
}
fmt.Printf("desactivados: %d usuarios\n", n)
Notas
Agnóstica al driver. Para DDL algunos drivers retornan 0 en RowsAffected — esto es normal. Para INSERT con last_insert_id usar DBInsertRow que retorna ese valor. Para multiples filas en una transaccion usar DBInsertBatch.