Files
archived-rttys/database.go
Jianhui Zhao 978d87ebc1 feat: support build statically
Use `modernc.org/sqlite` implemented in pure go,
so we can building with `CGO_ENABLED=0`.

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
2022-05-03 00:26:34 +08:00

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)
}
}