Skip to content

Instantly share code, notes, and snippets.

@bliaxiong
Created December 31, 2014 06:25
Show Gist options
  • Select an option

  • Save bliaxiong/562a36d9bda596002efa to your computer and use it in GitHub Desktop.

Select an option

Save bliaxiong/562a36d9bda596002efa to your computer and use it in GitHub Desktop.
Go mysql sqlx example
package main
import (
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
"log"
)
type User struct {
Id int
First, Last, Email string
}
func main() {
db, err := sqlx.Connect("mysql", "test:test@(localhost:3306)/test")
if err != nil {
log.Fatalln(err)
}
user := []User{}
db.Select(&user, "select * from users")
log.Println("users...")
log.Println(user)
}
@odil5
Copy link
Copy Markdown

odil5 commented Apr 24, 2024

thanks for useful information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment