Skip to content

Commit

Permalink
# Add durable package
Browse files Browse the repository at this point in the history
*CreateDatabase
*SetColumn
  • Loading branch information
JonyBepary committed Oct 18, 2023
1 parent 127841b commit 3361370
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/durable/database.go
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
package durable

import (
"database/sql"
"fmt"
"log"

_ "github.com/glebarez/go-sqlite"
)

// create a database connection to a file path
func CreateDatabase(path string) (*sql.DB, error) {
db, err := sql.Open("sqlite", path)
if err != nil {
log.Fatal(err)
}
return db, err
}

func SetColumn(col, col_types []string) string {
STR := ""
for i := 0; i < len(col); i++ {
STR += fmt.Sprintf("%v %v, ", col[i], col_types[i])
}
return STR[:len(STR)-2]
}

0 comments on commit 3361370

Please sign in to comment.