当前位置:网站首页>【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("连接成功")
}
边栏推荐
猜你喜欢

参与开源社区还有证书拿?

(十一)STM32——IO引脚复用与映射

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

Analyze optimism replay contract address attack events

Sentinel installation diagram

ContextLoaderListener vs DispatcherServlet

Static distribution and dynamic distribution in trust

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

MySQL六十六问,两万字+五十图详解含(答案解析)

训练和测试的loss不下降,并且精度超低
随机推荐
Chi square distribution, analysis of variance
强化学习---马尔可夫决策过程 MP MRP MDP
机器学习(9)——特征工程(3)(补充)
为什么香港服务器可以免备案
Analyze the CPU surge of an RFID tag system written by.Net
Solutions to sap Hana database backup failure
(十一)STM32——IO引脚复用与映射
jps详解
PDO操作
Seata
tp&smarty使用日记
非继承多态思路配合typeid实现不同参数的传递
配置Gom引擎登錄器出現錯誤提示:沒有發現必備補丁文件!
Pdman, a database modeling tool comparable to PowerDesigner [easy to understand]
There is an error prompt when configuring the GOM engine login: the necessary patch file is not found!
MySQL主从同步延迟解决方案
几种运维工具的对比
TwinCAT 3 first run error 4115
Rust中的dyn关键字
基于C语言开发的控制台计算器