package main import ( "fmt" "upper.io/db.v3/mysql" ) func main() { settings := mysql.ConnectionURL{ Host: "localhost", Database: "mydatabase", User: "myuser", Password: "mypassword", } sess, err := mysql.Open(settings) if err != nil { panic(err) } defer sess.Close() collection := sess.Collection("mytable") var results []struct { ID int `db:"id"` Name string `db:"name"` } err = collection.Find().All(&results) if err != nil { panic(err) } fmt.Println(results) }
package main import ( "fmt" "upper.io/db.v3/postgresql" ) func main() { settings := postgresql.ConnectionURL{ Host: "localhost", Database: "mydatabase", User: "myuser", Password: "mypassword", } sess, err := postgresql.Open(settings) if err != nil { panic(err) } defer sess.Close() collection := sess.Collection("mytable") err = collection.Find("id = ?", 42).Update(map[string]interface{}{"name": "newname"}) if err != nil { panic(err) } fmt.Println("Record updated successfully") }Package library: upper.io.db.