增加数据库配置:默认 sqlite3、支持 mysql,启动时连接校验

This commit is contained in:
2026-08-14 18:16:39 +08:00
parent 21be6e63af
commit 7e76dc5eae
7 changed files with 277 additions and 12 deletions
+8
View File
@@ -14,6 +14,7 @@ import (
"myaibot/internal/bot"
"myaibot/internal/cli"
"myaibot/internal/config"
"myaibot/internal/store"
)
func main() {
@@ -21,6 +22,13 @@ func main() {
if err != nil {
log.Fatalf("加载配置失败: %v", err)
}
db, err := store.Open(&cfg.Database)
if err != nil {
log.Fatalf("数据库连接失败: %v", err)
}
defer store.Close(db)
fmt.Printf("💾 数据库已连接 (%s)\n", cfg.Database.Driver)
b, err := bot.New(cfg)
if err != nil {
fmt.Printf("⚠️ %v\n", err)