polycule-connect/polyculeconnect/services/db/db.go
Melora Hugues d89ce46a47
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
wip
2024-03-29 18:21:26 +01:00

27 lines
574 B
Go

package db
import (
"database/sql"
"errors"
"fmt"
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/config"
)
type concreteDBService struct {
}
func connectSQLite(path string) (*sql.DB, error) {
return sql.Open("sqlite3", path)
}
func Connect(conf *config.AppConfig) (*sql.DB, error) {
switch conf.StorageType {
case string(config.Memory):
return nil, errors.New("no db for memory mode")
case string(config.SQLite):
return connectSQLite(conf.StorageConfig.File)
default:
return nil, fmt.Errorf("unsupported storage mode %q", conf.StorageType)
}
}