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
+46.2k Golang : Read tab delimited file with encoding/csv package
+20.5k Golang : Pipe output from one os.Exec(shell command) to another command
+6.9k Golang : Calculate BMI and risk category
+9.3k Golang : Temperatures conversion example
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+15.7k Golang : Get checkbox or extract multipart form data value example
+7.7k Golang : Command line ticker to show work in progress
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+8.4k Your page has meta tags in the body instead of the head
+5.7k Golang : Struct field tags and what is their purpose?
+37.7k Golang : Comparing date or timestamp
+9.4k Golang : Find the length of big.Int variable example