Golang database/sql.Stmt.Query function examples
package database/sql
Query executes a prepared query statement with the given arguments and returns the query results as a *Rows.
Golang database/sql.Stmt.Query function usage examples
Example 1:
func (dbt *DBTest) mustQuery(query string, args ...interface{}) (rows *sql.Rows) {
rows, err := dbt.db.Query(query, args...) // <--- here
if err != nil {
dbt.fail("Query", query, err)
}
return rows
}
Example 2:
var db = openDB()
stmt, _ := db.Prepare("select created_on from staffs")
rows, _ := stmt.Query() // <--- here
for rows.Next() {
time1 := new(time.Time)
rows.Scan(time1)
...
}
References :
https://github.com/go-sql-driver/mysql/blob/master/driver_test.go
Advertisement
Something interesting
Tutorials
+5.8k Unix/Linux : Get reboot history or check when was the last reboot date
+18.4k Golang : How to get hour, minute, second from time?
+6.3k Golang : Detect face in uploaded photo like GPlus
+7.7k Golang : Mapping Iban to Dunging alphabets
+9.9k Golang : ffmpeg with os/exec.Command() returns non-zero status
+10.6k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+11.9k Golang : How to parse plain email text and process email header?
+16.7k Golang : Gzip file example
+15.2k JavaScript/JQuery : Detect or intercept enter key pressed example
+8k Golang : Handle Palindrome string with case sensitivity and unicode
+4.5k Java : Generate multiplication table example