栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Go database / sql包中查看带有参数的查询

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Go database / sql包中查看带有参数的查询

它看起来不像在查询本身中插入参数。它发送查询,然后等待响应以发送参数。我分叉了pq并放入了一些日志代码-这是一个简单查询的输出:

 wes-macbook:testpq go run testpq.go2014/01/03 19:08:56 bytes: [0 0 0 84 0 3 0 0 101 120 116 114 97 95 102 108 111 97 116 95 100 105 103 105 116 115 0 50 0 99 108 105 101 110 116 95 101 110 99 111 100 105 110 103 0 85 84 70 56 0 100 97 116 101 115 116 121 108 101 0 73 83 79 44 32 77 68 89 0 117 115 101 114 0 119 102 114 101 101 109 97 110 0 0]2014/01/03 19:08:56 string: Textra_float_digits2client_encodingUTF8datestyleISO, MDYuserwfreeman2014/01/03 19:08:56 bytes: [80 0 0 0 45 0 115 101 108 101 99 116 32 42 32 102 114 111 109 32 116 101 115 116 32 119 104 101 114 101 32 116 101 115 116 46 110 97 109 101 61 36 49 0 0 0]2014/01/03 19:08:56 string: P-select * from test where test.name=$12014/01/03 19:08:56 bytes: [68 0 0 0 6 83 0]2014/01/03 19:08:56 string: DS2014/01/03 19:08:56 bytes: [83 0 0 0 4]2014/01/03 19:08:56 string: S2014/01/03 19:08:56 bytes: [66 0 0 0 20 0 0 0 0 0 1 0 0 0 4 97 115 100 102 0 0]2014/01/03 19:08:56 string: Basdf2014/01/03 19:08:56 bytes: [69 0 0 0 9 0 0 0 0 0]2014/01/03 19:08:56 string: E2014/01/03 19:08:56 bytes: [83 0 0 0 4]2014/01/03 19:08:56 string: S

我所做的只是调整send()代码:

func (cn *conn) send(m *writeBuf) {   b := (*m)[1:]   binary.BigEndian.PutUint32(b, uint32(len(b)))   if (*m)[0] == 0 {      *m = b   }   // new pre here   log.Println("bytes:", *m)   log.Println("string:", string(*m))   _, err := cn.c.Write(*m)   if err != nil {      panic(err)   }}

我的示例代码虽然很琐碎:https :
//gist.github.com/8249430



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/436332.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号