当前位置:网站首页>【215】gin框架連接mysql數據庫
【215】gin框架連接mysql數據庫
2022-07-23 18:05: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("連接成功")
}
边栏推荐
- Rust中的dyn关键字
- idea debug常用操作
- Common operations of idea debug
- IDEA这些既好用又好玩的三十多个宝贝插件你还不知道吗?「建议收藏」
- 分析一个 .NET 写的 某 RFID标签系统 CPU暴涨
- Analyze the CPU surge of an RFID tag system written by.Net
- The difference between function and method in rust
- Detailed explanation of curl command [easy to understand]
- WARNING: Your password has expired.Password change required but no TTY available.
- 非继承多态思路配合typeid实现不同参数的传递
猜你喜欢

c语言--通讯录的实现与ScreenToGif

ContextLoaderListener vs DispatcherServlet

rust中的静态分发和动态分发

Trust guessing numbers game

rust求数组中最大值

Sentinel 安装图解

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

Do you still have certificates to participate in the open source community?

Activity Registration: how to quickly start the open source tapdata live data platform on a zero basis?

Analyze the CPU surge of an RFID tag system written by.Net
随机推荐
Trust sums two numbers
测试开发面经
几种运维工具的对比
WARNING: Your password has expired.Password change required but no TTY available.
(11) STM32 - IO pin multiplexing and mapping
Createfilemapping function "suggestions collection"
TwinCAT 3 首次运行报错4115
分页类
c语言--通讯录的实现与ScreenToGif
New opportunities for cultural tourism in the era of digital intelligence? China Mobile Migu creates "the first island in the yuan universe"
Mongodb group one piece of data in each group
LDAP统一认证服务解决方案[通俗易懂]
Console calculator developed based on C language
Qt多线程实例与connect第五个参数[通俗易懂]
rust统计文件中单词出现的次数
网页基础模版
Don't you know more than 30 baby plug-ins like idea that are both easy to use and fun? "Suggested collection"
工作常用操作
Did not find the necessary patch file 'newopui.pak'?
Leetcode: Jianzhi offer II 115. reconstruction sequence [graph theory thinking + in degree consideration + topological sorting]