parent
bb36010ca0
commit
ee30606ddd
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"github.com/go-sql-driver/mysql"
|
"github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ImportDatabaseToString() {
|
func ImportDatabaseToString(dsn string) {
|
||||||
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Blocks-IPv4-string.csv")
|
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Blocks-IPv4-string.csv")
|
||||||
db, err := sql.Open("mysql", "root:990821@tcp(192.168.2.20:3306)/checkip")
|
db, err := sql.Open("mysql", dsn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("数据库连接错误:", err)
|
fmt.Println("数据库连接错误:", err)
|
||||||
return
|
return
|
||||||
|
|
@ -66,9 +66,9 @@ CREATE TABLE geolite2_city_ipv4_string (
|
||||||
fmt.Println("表geolite2_city_ipv4_string数据加载完成")
|
fmt.Println("表geolite2_city_ipv4_string数据加载完成")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImportDatabaseToHex() {
|
func ImportDatabaseToHex(dsn string) {
|
||||||
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Blocks-IPv4-hex.csv")
|
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Blocks-IPv4-hex.csv")
|
||||||
db, err := sql.Open("mysql", "root:990821@tcp(192.168.2.20:3306)/checkip")
|
db, err := sql.Open("mysql", dsn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("数据库连接错误:", err)
|
fmt.Println("数据库连接错误:", err)
|
||||||
return
|
return
|
||||||
|
|
@ -126,9 +126,9 @@ CREATE TABLE geolite2_city_ipv4_hex (
|
||||||
fmt.Println("表geolite2_city_ipv4_hex数据加载完成")
|
fmt.Println("表geolite2_city_ipv4_hex数据加载完成")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImportLocation_zhCN() {
|
func ImportLocation_zhCN(dsn string) {
|
||||||
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Locations-zh-CN.csv")
|
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Locations-zh-CN.csv")
|
||||||
db, err := sql.Open("mysql", "root:990821@tcp(192.168.2.20:3306)/checkip")
|
db, err := sql.Open("mysql", dsn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("数据库连接错误:", err)
|
fmt.Println("数据库连接错误:", err)
|
||||||
return
|
return
|
||||||
|
|
@ -188,9 +188,9 @@ set country_iso_code = nullif(@country_iso_code, ''),
|
||||||
fmt.Println("表geolite2_city_locations_zh_cn数据加载完成")
|
fmt.Println("表geolite2_city_locations_zh_cn数据加载完成")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImportLocation_en() {
|
func ImportLocation_en(dsn string) {
|
||||||
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Locations-en.csv")
|
mysql.RegisterLocalFile("C:/Users/wangh/Desktop/code/checkIP/db/GeoLite2-City-Locations-en.csv")
|
||||||
db, err := sql.Open("mysql", "root:990821@tcp(192.168.2.20:3306)/checkip")
|
db, err := sql.Open("mysql", dsn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("数据库连接错误:", err)
|
fmt.Println("数据库连接错误:", err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue