mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
Use `modernc.org/sqlite` implemented in pure go, so we can building with `CGO_ENABLED=0`. Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
26 lines
397 B
Go
26 lines
397 B
Go
/*
|
|
* @Author: 周家建
|
|
* @Mail: zhou_0611@163.com
|
|
* @Date: 2021-07-27 19:02:39
|
|
* @Description:
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"strings"
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
_ "modernc.org/sqlite"
|
|
)
|
|
|
|
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)
|
|
}
|
|
}
|