Answer the question
In order to leave comments, you need to log in
How to safely work with sql?
Hello. I did not find anything on the Internet about protection against sql injections in golang. Now there is a code
rows, err := DB.Query("SELECT * FROM dev_method WHERE name=?", ps.ByName("methods"))
if err != nil {
status.Code503(w, r)
}
defer rows.Close()
bks := make([]*dev_method, 0)
for rows.Next() {
bk := new(dev_method)
err := rows.Scan(&bk.id, &bk.id_menu, &bk.name, &bk.description)
if err != nil {
status.Code503(w, r)
}
bks = append(bks, bk)
}
if err = rows.Err(); err != nil {
status.Code503(w, r)
}
Answer the question
In order to leave comments, you need to log in
The request here is quite normally formed, using placeholders. There can be no SQL injection, because "?" is replaced by the value via escaping.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question