support sqlite

This commit is contained in:
rogee
2023-03-01 09:24:01 +08:00
parent bdee945461
commit bfe1870420
2 changed files with 6 additions and 3 deletions

View File

@@ -51,7 +51,10 @@ var modelCmd = &cobra.Command{
log.Fatal(err) log.Fatal(err)
} }
case database.DriverSQLite: case database.DriverSQLite:
err := gq.DB.Raw("SELECT name FROM sqlite_master WHERE type='table'").Scan(&tables).Error
if err != nil {
log.Fatal(err)
}
} }
if len(tables) == 0 { if len(tables) == 0 {

View File

@@ -88,7 +88,7 @@ ShowLine = true
LogInConsole = true LogInConsole = true
[Database] [Database]
Driver = "postgres" Driver = "sqlite"
[Database.MySQL] [Database.MySQL]
Host = "10.47.119.226" Host = "10.47.119.226"
@@ -116,7 +116,7 @@ MaxIdleConns = 10
MaxOpenConns = 200 MaxOpenConns = 200
[Database.SQLite] [Database.SQLite]
File = "sqlite.db" File = "data.db"
[Database.Redis] [Database.Redis]
Host = "10.47.119.226" Host = "10.47.119.226"