Reputation: 779
I'm unsure how to retrieve values from a prepared statement since result only returns information about the transaction.
statement, err := txn.Prepare(`SELECT id, password FROM public.user WHERE email = $1`)
result, err = stmt.Exec(email, password, email)
I understand Query() and QueryRow() have the intended result, but from what I understand, they are unsafe. Any help on this is appreciated, thanks.
Upvotes: 3
Views: 2454
Reputation: 99215
They are perfectly safe, you use it the same way, exec is really just for inserts:
stmt, err := txn.Prepare(`SELECT id, password FROM public.user WHERE email = $1`)
rows, err := stmt.Query(email)
Check: https://code.google.com/p/go-wiki/wiki/SQLInterface
Upvotes: 4