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
+9.4k Golang : Qt Yes No and Quit message box example
+14.4k Golang : How to convert a number to words
+6.9k Nginx : Password protect a directory/folder
+5.2k Golang : Calculate half life decay example
+46.4k Golang : Encode image to base64 example
+40.1k Golang : UDP client server read write example
+9.2k Golang : How to check if a string with spaces in between is numeric?
+8.6k Golang : Convert(cast) []byte to io.Reader type
+8.3k Golang : Auto-generate reply email with text/template package
+11.5k Use systeminfo to find out installed Windows Hotfix(s) or updates
+18.5k Golang : Example for RSA package functions