Golang database/sql.Tx.Query function examples
package database/sql
Query executes a query that returns rows, typically a SELECT.
Golang database/sql.Tx.Query function usage examples
Example 1:
rows, err := txn.Query("CREATE TEMP TABLE foo(f1 int)")
if err != nil {
t.Fatal(err)
}
Example 2:
var nick string
row, err := tx.Query(`select score from plusplus where nick = ?`, strings.ToLower(nick))
if err != nil {
fmt.Printf("Database error: %v\n", err)
return
}
Reference :
Advertisement
Something interesting
Tutorials
+24.5k Golang : GORM read from database example
+9.2k Golang : Create and shuffle deck of cards example
+51.4k Golang : Check if item is in slice/array
+10.1k Golang : Compare files modify date example
+7.3k Golang : File system scanning
+7k Golang : Gargish-English language translator
+16k Golang : Get sub string example
+35.3k Golang : Strip slashes from string example
+12.7k Golang : zlib compress file example
+31.1k Golang : Calculate percentage change of two values
+5k Golang : Calculate a pip value and distance to target profit example