12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package engine
- import (
- "net/url"
- "github.com/vladimirok5959/golang-sql/gosql/common"
- )
- // ----------------------------------------------------------------------------
- type mysql struct {
- *common.DBMethods
- }
- func NewMySQL(dbURL *url.URL, migrationsDir string, skipMigration bool, debug bool) (common.Engine, error) {
- db, err := common.OpenDB(dbURL, migrationsDir, skipMigration, debug)
- if err != nil {
- return nil, err
- }
- return &mysql{
- DBMethods: &common.DBMethods{
- DB: db,
- Debug: debug,
- Driver: dbURL.Scheme,
- },
- }, nil
- }
- // ----------------------------------------------------------------------------
- type postgresql struct {
- *common.DBMethods
- }
- func NewPostgreSQL(dbURL *url.URL, migrationsDir string, skipMigration bool, debug bool) (common.Engine, error) {
- db, err := common.OpenDB(dbURL, migrationsDir, skipMigration, debug)
- if err != nil {
- return nil, err
- }
- return &postgresql{
- DBMethods: &common.DBMethods{
- DB: db,
- Debug: debug,
- Driver: dbURL.Scheme,
- },
- }, nil
- }
- // ----------------------------------------------------------------------------
- type sqlite struct {
- *common.DBMethods
- }
- func NewSQLite(dbURL *url.URL, migrationsDir string, skipMigration bool, debug bool) (common.Engine, error) {
- db, err := common.OpenDB(dbURL, migrationsDir, skipMigration, debug)
- if err != nil {
- return nil, err
- }
- return &sqlite{
- DBMethods: &common.DBMethods{
- DB: db,
- Debug: debug,
- Driver: dbURL.Scheme,
- },
- }, nil
- }
|