Files
ersteller/sqlite.go
T
2025-11-15 12:04:39 +01:00

30 lines
623 B
Go

package ersteller
import (
"context"
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
// CreateSQLiteConnpool creates a new SQLite connection pool
func CreateSQLiteConnpool(dbPath string) (*sql.DB, error) {
db, err := sql.Open("sqlite3", dbPath)
if err != nil {
Error("Error while creating connection to the SQLite database!!", err)
return nil, err
}
// Test the connection
err = db.PingContext(context.Background())
if err != nil {
LogError("Could not ping SQLite database: %v", err)
return nil, err
}
// Set connection pool settings
db.SetMaxOpenConns(4)
db.SetMaxIdleConns(2)
return db, nil
}