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
+17.4k Golang : Check if IP address is version 4 or 6
+18.6k Golang : Find IP address from string
+14.6k Golang : How to get URL port?
+5.3k Python : Convert(cast) string to bytes example
+7.9k Golang : Ways to recover memory during run time.
+11.5k Golang : Change date format to yyyy-mm-dd
+17.7k Golang : [json: cannot unmarshal object into Go value of type]
+15k Golang : package is not in GOROOT during compilation
+17.9k Golang : Qt image viewer example
+25.9k Golang : How to read integer value from standard input ?
+5.1k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+25k Golang : Create PDF file from HTML file