You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
871 B
31 lines
871 B
package sqlx |
|
|
|
import ( |
|
"context" |
|
"database/sql" |
|
) |
|
|
|
func exec(ctx context.Context, conn sessionConn, q string, args ...any) (sql.Result, error) { |
|
result, err := conn.ExecContext(ctx, q, args...) |
|
return result, err |
|
} |
|
func query(ctx context.Context, conn sessionConn, scanner func(rows *sql.Rows) error, q string, args ...any) error { |
|
rows, err := conn.QueryContext(ctx, q, args...) |
|
if err != nil { |
|
return err |
|
} |
|
defer rows.Close() |
|
return scanner(rows) |
|
} |
|
func queryStmt(ctx context.Context, conn stmtConn, scanner func(rows *sql.Rows) error, query string, args ...any) error { |
|
rows, err := conn.QueryContext(ctx, args...) |
|
if err != nil { |
|
return err |
|
} |
|
defer rows.Close() |
|
return scanner(rows) |
|
} |
|
func execStmt(ctx context.Context, conn stmtConn, q string, args ...any) (sql.Result, error) { |
|
result, err := conn.ExecContext(ctx, args...) |
|
return result, err |
|
}
|
|
|