golang sql builder tool, similar to mybatis.
follow the example of github.com/jmoiron/sqlx
go get github.com/xuruiray/gosql
- # represents string splicing
- $ represents prepare statement placeholder
test sql
select * from #tablename where driver_id = $driver_id #sorttest table info (MySQL 5.7.18)
--table info
CREATE TABLE `driver_info` (
`id` int(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`driver_id` int(20) NOT NULL DEFAULT '0' COMMENT '司机ID',
`name` varchar(20) COLLATE utf8_bin NOT NULL DEFAULT '0' COMMENT '司机姓名',
`age` int(20) NOT NULL DEFAULT '0' COMMENT '司机年龄',
PRIMARY KEY (`id`),
KEY `inx_driver_id_age` (`driver_id`,`age`)
) ENGINE=InnoDB AUTO_INCREMENT=124 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--row info
INSERT INTO `driver_info` (`id`, `driver_id`, `name`, `age`)
VALUES
(123,456,X'7875727569',12),
(124,457,X'7875727569',13),
(125,458,X'7875727569',14),
(126,459,X'7875727569',15);