Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
func main() {
// Create the database handle, confirm driver is present
db, _ := sql.Open("mysql", "root:password@/4image")
defer db.Close()
// Connect and check the server version
var version string
db.QueryRow("SELECT VERSION()").Scan(&version)
fmt.Println("Connected to:", version)
var name string
db.QueryRow("select cat_name from 4images_categories limit 1").Scan(&name)
fmt.Println("cat name =", name)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.