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
+7.4k Android Studio : How to detect camera, activate and capture example
+14.5k Golang : Overwrite previous output with count down timer
+12.5k Golang : Arithmetic operation with numerical slices or arrays example
+7.4k Golang : Individual and total number of words counter example
+7.6k Golang : Convert(cast) io.Reader type to string
+19.9k Golang : How to get time from unix nano example
+9k Golang : Populate or initialize struct with values example
+12.3k Golang : List running EC2 instances and descriptions
+18.6k Golang : Generate thumbnails from images
+6.2k PHP : Get client IP address
+28.2k Golang : Connect to database (MySQL/MariaDB) server