26 lines
521 B
Go
26 lines
521 B
Go
package db
|
|
|
|
import (
|
|
"github.com/glebarez/sqlite"
|
|
"gorm.io/driver/mysql"
|
|
"gorm.io/driver/postgres"
|
|
"gorm.io/driver/sqlserver"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func connectMySQL(dsn string) gorm.Dialector {
|
|
return mysql.Open(dsn)
|
|
}
|
|
|
|
func connectSQLite(filepath string) gorm.Dialector {
|
|
return sqlite.Open(filepath + "?cache=shared&_fk=1&_driver=modernc.org/sqlite")
|
|
}
|
|
|
|
func connectPostgres(dsn string) gorm.Dialector {
|
|
return postgres.Open(dsn)
|
|
}
|
|
|
|
func connectSQLServer(dsn string) gorm.Dialector {
|
|
return sqlserver.Open(dsn)
|
|
}
|