From 01a64b38c70aa111683ed5b75891a1aee664e2e1 Mon Sep 17 00:00:00 2001 From: John Cardarelli Date: Thu, 12 Oct 2023 09:50:19 -0700 Subject: [PATCH] Parameterize dbFile location for InitSqlDatabase --- cmd/init.go | 2 +- database/sqlite.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 8383bfc..8ebce33 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -18,7 +18,7 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - err := db.InitSqlDatabase() + err := db.InitSqlDatabase("fancy-cli.db") if err != nil { log.Fatalln(err) } diff --git a/database/sqlite.go b/database/sqlite.go index 516de95..f2373db 100644 --- a/database/sqlite.go +++ b/database/sqlite.go @@ -26,9 +26,9 @@ func OpenConnectionPool(sqliteDbFile string) error { } // Setup database connection -func InitSqlDatabase() error { +func InitSqlDatabase(dbFile string) error { // Attempt to open a connection to the sqlite file - connErr := OpenConnectionPool("fancy-cli.db") + connErr := OpenConnectionPool(dbFile) if connErr != nil { log.Fatalln("error connecting to sqlite", connErr) }