mirror of
https://github.com/netfun2000/rttys_zhaojh329.git
synced 2026-02-27 09:53:24 +08:00
9527ae775c
Signed-off-by: zhou_jiajian <zhou_0611@163.com>
24 lines
404 B
Go
24 lines
404 B
Go
/*
|
|
* @Author: 周家建
|
|
* @Mail: zhou_0611@163.com
|
|
* @Date: 2021-07-27 19:02:39
|
|
* @Description:
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
"database/sql"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
func instanceDB(str string) (*sql.DB, error) {
|
|
sp:= strings.Split(str, "://")
|
|
if len(sp) == 2 {
|
|
return sql.Open(sp[0], sp[1])
|
|
} else {
|
|
return sql.Open("mysql", str)
|
|
}
|
|
} |