当前位置:网站首页>[215] gin framework connects to MySQL database
[215] gin framework connects to MySQL database
2022-07-23 18:05:00 【Milo mouth】
package main
import (
"fmt"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main(){
db,err:=sql.Open("mysql","root:[email protected](127.0.0.1:3306)/djangoblog")
if err != nil{
panic(err)
}
defer db.Close()
if err:=db.Ping();err!=nil{
fmt.Println(" The connection fails ")
panic(err)
}
fmt.Println(" Successful connection ")
}
边栏推荐
- 作为一名后台开发人员,你必须知道的两种过滤器
- As a background developer, you must know two kinds of filters
- vim 笔记
- Mongodb group one piece of data in each group
- LeetCode_动态规划_中等_120.三角形最小路径和
- PDO操作
- MySQL7种JOIN(图)
- Sentinel introduction and microservice integration
- TYPE-C 转OTG(USB2.0传输数据)+PD充电协议芯片 乐得瑞LDR6028/LDR6023SS
- Docker installs redis and starts it as a configuration file
猜你喜欢
随机推荐
rust求数组中最大值
CSDN定制T恤等你来拿,《新程序员》福利来袭!
【215】gin框架连接mysql数据库
LDAP统一认证服务解决方案[通俗易懂]
mysqldump的各项参数
Mpu9250 sensor
MySQL7种JOIN(图)
Server environment setup
Rust中的函数function与方法method的区别
RS232 DB9串口设备
Don't you know more than 30 baby plug-ins like idea that are both easy to use and fun? "Suggested collection"
卡方分布、方差分析
MySQL大量写入问题优化方案 MySQL参数调优
微服务雪崩问题及解决方案
Multithreaded programming
Microservice avalanche problems and Solutions
TYPE-C 转OTG(USB2.0传输数据)+PD充电协议芯片 乐得瑞LDR6028/LDR6023SS
Paging class
Sublime text tips
(十一)STM32——IO引脚复用与映射









