Permalink
Browse files

update readme

  • Loading branch information...
1 parent 3bcffda commit 0e69f7b0f30daa26fb7552ce03d867d91e0b84d2 @eden committed Nov 28, 2009
Showing with 16 additions and 16 deletions.
  1. +16 −16 README.markdown
View
32 README.markdown
@@ -21,23 +21,23 @@ Example
Synopsis
--------
- conn := mysql.NewConn();
- err := conn.Connect(&mysql.ConnInfo{host, port, user, pass, dbname});
- if err != nil { panic("Connect error") }
-
- cur := conn.Cursor();
- cur.Execute("SELECT * FROM table");
- tuple, err := cur.FetchOne();
- for ; err == nil && tuple != nil; tuple, err = cur.FetchOne() {
- fmt.Println(tuple)
+ conn, err := mysql.Open(map[string]interface{} {
+ "host": "127.0.0.1",
+ "port": 3306,
+ "username": "root"
+ });
+ if err != nil { panic("Connect error:", err) }
+
+ stmt, serr := conn.Prepare("SELECT * FROM table");
+ if serr != nil { panic("Prepare error:", serr) }
+
+ cur, cerr := conn.Execute(stmt);
+ if cerr != nil { panic("Execute error:", cerr) }
+
+ for t, _ := cur.FetchOne(); t != nil; t, _ = cur.FetchOne() {
+ fmt.Println(t)
}
cur.Close();
+ stmt.Close();
conn.Close();
-
-TODO
-----
-- Proper type conversion. Right now all values are returned as strings.
-- More tests.
-- Better documentation.
-- Connection pools?

0 comments on commit 0e69f7b

Please sign in to comment.