package db

import (
	"database/sql"

	_ "github.com/mattn/go-sqlite3"
)

func Truncate(db *sql.DB, table string) {
	db.Exec("DELETE FROM " + table + ";")
	db.Exec("UPDATE SQLITE_SEQUENCE SET seq = 0 WHERE name = '<table>" + table + "';")
}

func Connect(file string) (*sql.DB, error) {
	if file == "" {
		file = "data.db"
	}

	db, err := sql.Open("sqlite3", file)
	if err != nil {
		return nil, err
	}
	return db, nil
}
