mysql网络协议,go-mysql MySQL网络协议库

go-mysql 是一个功能强大的 MySQL 协议处理工具集,你可以使用 client 连接操作 MySQL,使用 server 制作自己的 MySQL proxy,使用 replication 同步 MySQL 的 binlog,使用 canal 进行 MySQL 到其他服务(Elasticsearch,Redis)的数据实时更新。

示例代码:

import (    "github.com/siddontang/go-mysql/client")// Connect MySQL at 127.0.0.1:3306, with user root, an empty passowrd and database testconn, _ := client.Connect("127.0.0.1:3306", "root", "", "test")conn.Ping()// Insertr, _ := conn.Execute(`insert into table (id, name) values (1, "abc")`)// Get last insert idprintln(r.InsertId)// Selectr, _ := conn.Execute(`select id, name from table where id = 1`)// Handle resultsetv, _ := r.GetInt(0, 0)v, _ = r.GetIntByName(0, "id")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值