Created
March 19, 2014 05:55
-
-
Save anidotnet/9636189 to your computer and use it in GitHub Desktop.
MySQL test
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 ( | |
"log" | |
"upper.io/db" | |
_ "upper.io/db/mysql" | |
) | |
var settings = db.Settings{ | |
Host: "localhost", // MySQL server IP or name. | |
Database: "blog", // Database name. | |
User: "root", // Optional user name. | |
Password: "*******", // Optional user password. | |
} | |
type Test struct { | |
firstName string `field:"firstname"` | |
lastName string `field:"lastname"` | |
} | |
func main() { | |
sess, err := db.Open("mysql", settings) | |
if err != nil { | |
panic(err.Error()) | |
} | |
col, err := sess.Collection("test") | |
log.Println(col.Name()) | |
col.Append(Test{ | |
"abcd", | |
"xyz", | |
}) | |
sess.Close() | |
if err != nil { | |
panic(err.Error()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment