Skip to content

Commit

Permalink
Parameterize dbFile location for InitSqlDatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
jcardarelli committed Oct 12, 2023
1 parent 83f5a6c commit 01a64b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions database/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 01a64b3

Please sign in to comment.