foodoles/bdd/bdd.go

33 lines
482 B
Go

package bdd
import (
"bufio"
"encoding/csv"
"fmt"
bolt "go.etcd.io/bbolt"
"io"
"log"
"os"
)
// BUCKET est le nom de la base
var BUCKET = "FoodBucket"
// InitBDD initialise la BDD
func InitBDD() bolt.DB {
db, err := bolt.Open("foods.db", 0600, nil)
if err != nil {
log.Fatal(err)
}
db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket([]byte(BUCKET))
if err != nil {
return fmt.Errorf("create bucket: %s", err)
}
log.Print(b)
return nil
})
}