mysqlgo

Go 安裝 與 設定上的疑難雜症

mysqlgo

文章kevinwatt » 2009年 12月 17日, 15:31

MySQL bindings for Go
是go的mysql clinet library.
網站位於 http://github.com/eden/mysqlgo

安裝非常簡單 ( ubuntu 需要裝 libmysqlclient-dev 裡面會用到 mysql_config )
$ git clone git://github.com/eden/mysqlgo.git
$ cd mysqlgo
$ make install
$ make example
$ ./example -host=127.0.0.1 -user=root -dbname=test


使用容易
代碼: 選擇全部
package main
import (    "mysql";     "fmt";    "rand"; )
func main(){
  conn, _ := mysql.Open(fmt.Sprintf("mysql://go:gogogo@127.0.0.1:3306/godb"));
  stmt, _ := conn.Prepare("CREATE TABLE hello (i INT, s VARCHAR(255))");
  conn.Execute(stmt);
  stmt, _ = conn.Prepare("INSERT INTO hello (i, s) VALUE (?, ?)");
  for i := 0; i < 100; i += 1 {
    conn.Execute(stmt, rand.Int(), fmt.Sprintf("id%d", rand.Int()));
  }
  stmt, _ = conn.Prepare("SELECT * from hello");
  rs, _ := conn.Execute(stmt);
  for res := range rs.Iter() {
    row := res.Data();
    fmt.Printf("%d %s\n", row[0], row[1])
  }
  stmt.Close(); conn.Close();
}
頭像
kevinwatt
系統管理員
 
文章: 77
註冊時間: 2009年 12月 1日, 22:39

Re: mysqlgo

文章Soul|銀魂 » 2009年 12月 17日, 19:46

我在这里使用的是

./example -host=127.0.0.1 -user=root -database=test


太强大了.... :lol: :lol: :lol:
圖檔
頭像
Soul|銀魂
 
文章: 5
註冊時間: 2009年 12月 15日, 09:20

Re: mysqlgo

文章kevinwatt » 2009年 12月 18日, 14:56

Soul|銀魂 寫:我在这里使用的是

./example -host=127.0.0.1 -user=root -database=test


太强大了.... :lol: :lol: :lol:


這就是安裝的最後一步吧... 哈. :)
頭像
kevinwatt
系統管理員
 
文章: 77
註冊時間: 2009年 12月 1日, 22:39

Re: mysqlgo

文章Soul|銀魂 » 2009年 12月 19日, 00:29

kevinwatt 寫:
Soul|銀魂 寫:我在这里使用的是

./example -host=127.0.0.1 -user=root -database=test


太强大了.... :lol: :lol: :lol:


這就是安裝的最後一步吧... 哈. :)


是的 这里就是一个测试 MysqlGo 应用的脚本 @onion24@ @onion24@
圖檔
頭像
Soul|銀魂
 
文章: 5
註冊時間: 2009年 12月 15日, 09:20


回到 Go 安裝

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客

cron