This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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