1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

WIP: SQLite support.

This commit is contained in:
Ferdinand Mütsch 2020-03-31 14:43:15 +02:00
parent 34037d2957
commit 1e5ec48748
4 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
ENV=prod ENV=prod
WAKAPI_DB_TYPE=mysql WAKAPI_DB_TYPE=mysql # mysql, postgres, sqlite3
WAKAPI_DB_NAME=wakapi_db # file path for sqlite, e.g. /tmp/wakapi.db
WAKAPI_DB_USER=myuser WAKAPI_DB_USER=myuser
WAKAPI_DB_PASSWORD=mysecretpassword WAKAPI_DB_PASSWORD=shhh
WAKAPI_DB_HOST=localhost WAKAPI_DB_HOST=localhost
WAKAPI_DB_PORT=3306 WAKAPI_DB_PORT=3306
WAKAPI_DB_NAME=wakapi_db

1
go.sum
View File

@ -65,6 +65,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4= github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=

View File

@ -28,6 +28,7 @@ import (
_ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/mysql"
_ "github.com/jinzhu/gorm/dialects/postgres" _ "github.com/jinzhu/gorm/dialects/postgres"
_ "github.com/jinzhu/gorm/dialects/sqlite"
) )
// TODO: Refactor entire project to be structured after business domains // TODO: Refactor entire project to be structured after business domains

View File

@ -36,6 +36,8 @@ func MakeConnectionString(config *models.Config) string {
return mySqlConnectionString(config) return mySqlConnectionString(config)
case "postgres": case "postgres":
return postgresConnectionString(config) return postgresConnectionString(config)
case "sqlite3":
return sqliteConnectionString(config)
} }
return "" return ""
} }
@ -62,3 +64,7 @@ func postgresConnectionString(config *models.Config) string {
config.DbPassword, config.DbPassword,
) )
} }
func sqliteConnectionString(config *models.Config) string {
return config.DbName
}