水军大提督 发表于 2023-6-13 15:10:58

Go 语言之 sqlx 库使用

Go 语言之 sqlx 库使用

一、sqlx 库安装与连接

sqlx 介绍

sqlx is a library which provides a set of extensions on go's standard database/sql library. The sqlx versions of sql.DB, sql.TX, sql.Stmt, et al. all leave the underlying interfaces untouched, so that their interfaces are a superset on the standard ones. This makes it relatively painless to integrate existing codebases using database/sql with sqlx.
Sqlx 是一个库,它在 go 的标准数据库/sql 库上提供了一组扩展。
sqlx库:https://github.com/jmoiron/sqlx
Illustrated guide to SQLX:http://jmoiron.github.io/sqlx/
sqlx:https://pkg.go.dev/github.com/jmoiron/sqlx
安装

go get github.com/jmoiron/sqlx创建 sqlx_demo 项目

https://raw.githubusercontent.com/qiaopengjun5162/blogpicgo/master/img202306112235131.png
https://raw.githubusercontent.com/qiaopengjun5162/blogpicgo/master/img202306112235131.png
创建 main.go 文件

https://raw.githubusercontent.com/qiaopengjun5162/blogpicgo/master/img202306112239546.png
https://raw.githubusercontent.com/qiaopengjun5162/blogpicgo/master/img202306112239546.png
使用go mod tidy 添加丢失的模块和删除未使用的模块

go mod tidy   add missing and remove unused modules

Code/go/sqlx_demo via
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: Go 语言之 sqlx 库使用