Beispiel #1
0
func execSql(db *sqlx.DB, sql string) {
	stmt, err := db.Prepare(sql)
	checkErr(err)

	_, err = stmt.Exec()

	checkErr(err)
}
Beispiel #2
0
func DeletePost(db *sqlx.DB, uid int) {
	stmt, err := db.Prepare("delete from posts where uid=$1")
	checkErr(err)

	res, err := stmt.Exec(uid)
	checkErr(err)

	affect, err := res.RowsAffected()
	checkErr(err)

	fmt.Println(affect, "rows changed")
}