my gosqlite statement is not executing . its gets value from status and stops there . Can anyone help me. also after running its goes upto status then its does nothing and terminal cursor is blinking.
package update
import (
"bufio"
"fmt"
"os"
"strings"
// "log"
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
func Updatemac(db *sql.DB) {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter MAC Address to update: ")
MAC_Address, _ := reader.ReadString('\n')
if MAC_Address != "\n" {
MAC_Address = strings.TrimSuffix(MAC_Address, "\n")
}
/// rows, _ := db.Query("SELECT * From wd WHERE MAC_Address = ?")
// fmt.Print(rows)
// defer rows.Close()
// for rows.Next() {
// rows.Scan(&MAC_Address)
// }
fmt.Print("Status :")
Status, _ := reader.ReadString('\n')
if Status != "\n" {
Status = strings.TrimSuffix(Status, "\n")
}
Stmt, err := db.Prepare("UPDATE wd SET Status = ? WHERE MAC_Address = ?")
checkErr(err)
defer Stmt.Close()
Stmt.Exec(Status, MAC_Address)
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}