package main

import (
	"database/sql"

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

type model struct {
	db     *sql.DB
	isOpen bool
}

func canOpenDB(fn string) bool {
	db, err := sql.Open("sqlite3", fn)
	defer db.Close()
}

func (m *model) Open(fn string) error {
	var err error
	if !m.isOpen {
		m.db, err = sql.Open("sqlite3", fn)
		m.isOpen = true
	}
	return err
}

func (m *model) Close() {
	if m.isOpen {
		m.db.Close()
		m.isOpen = false
	}
}
