当前位置:网站首页>【215】gin框架连接mysql数据库
【215】gin框架连接mysql数据库
2022-07-23 15:36:00 【米洛口】
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("连接失败")
panic(err)
}
fmt.Println("连接成功")
}
边栏推荐
- Why can Hong Kong servers be exempted from filing
- (11) STM32 - IO pin multiplexing and mapping
- keyup.native在el-input中的使用
- Chi square distribution, analysis of variance
- CSDN custom T-shirts are waiting for you to get, and the benefits of new programmer are coming!
- 网页基础模版
- 能与PowerDesigner媲美的数据库建模工具PDMan[通俗易懂]
- 服务器环境搭建
- The use method of quota command is expanded in detail, and the carrying method of quota command in RHEL 7! Disk capacity quota!
- Une erreur s'est produite lors de la configuration du login du moteur Gom: aucun correctif requis n'a été trouvé!
猜你喜欢

New opportunities for cultural tourism in the era of digital intelligence? China Mobile Migu creates "the first island in the yuan universe"

没有发现必备补丁文件‘NewopUI.pak’?

leetcode刷题:动态规划04(不同路径)

微服务雪崩问题及解决方案

Keras之二分类问题

Research and implementation of network multi exit design based on policy routing deployment

TwinCAT 3 first run error 4115

Trust guessing numbers game

Aike AI frontier promotion (7.23)

Console calculator developed based on C language
随机推荐
MySQL执行Alter table xx add column报Duplicate entry错误
Mpu9250 sensor
The difference between function and method in rust
Reinforcement learning -- Markov decision process MP MRP MDP
基于C语言开发的控制台计算器
Dyn keyword in rust
Sublime text tips
传奇架设 GEE引擎教程 配置微端
Repository XXX does not have a rease file "suggested collection"
Solutions to sap Hana database backup failure
几种运维工具的对比
CSDN custom T-shirts are waiting for you to get, and the benefits of new programmer are coming!
Tampermonkey究竟有什么用?
CSDN定制T恤等你来拿,《新程序员》福利来袭!
Tapdata 与优炫数据库完成产品兼容性互认证
Eric6安装问题
封玩家IP和机器码以及解开被封的教程
docker安装redis并以配置文件方式启动
sublime text使用技巧
RS232 DB9 serial port device