<commit_before>package qbit

import "database/sql"

func NewEngine(driver string, dsn string) (*Engine, error) {

	conn, err := sql.Open(driver, dsn)
	if err != nil {
		return nil, err
	}

	return &Engine{
		driver: driver,
		dsn:    dsn,
		db:     conn,
	}, err
}

type Engine struct {
	driver string
	dsn    string
	db     *sql.DB
}

func (e *Engine) Exec(sql string, bindings []interface{}) (sql.Result, error) {

	stmt, err := e.db.Prepare(sql)
	if err != nil {
		return nil, err
	}

	res, err := stmt.Exec(bindings)
	if err != nil {
		return nil, err
	}

	return res, nil
}

func (e *Engine) DB() *sql.DB {
	return e.db
}

func (e *Engine) Ping() error {
	return e.db.Ping()
}

func (e *Engine) Driver() string {
	return e.driver
}

func (e *Engine) Dsn() string {
	return e.dsn
}<commit_msg>add comments, fix engine lint errors<commit_after>package qbit

import "database/sql"

// NewEngine generates a new engine and returns it as an engine pointer
func NewEngine(driver string, dsn string) (*Engine, error) {

	conn, err := sql.Open(driver, dsn)
	if err != nil {
		return nil, err
	}

	return &Engine{
		driver: driver,
		dsn:    dsn,
		db:     conn,
	}, err
}

// Engine is the generic struct for handling db connections
type Engine struct {
	driver string
	dsn    string
	db     *sql.DB
}

// Exec executes insert & update type queries and returns sql.Result and error
func (e *Engine) Exec(sql string, bindings []interface{}) (sql.Result, error) {

	stmt, err := e.db.Prepare(sql)
	if err != nil {
		return nil, err
	}

	res, err := stmt.Exec(bindings)
	if err != nil {
		return nil, err
	}

	return res, nil
}

// DB returns sql.DB of wrapped engine connection
func (e *Engine) DB() *sql.DB {
	return e.db
}

// Ping pings the db using connection and returns error if connectivity is not present
func (e *Engine) Ping() error {
	return e.db.Ping()
}

// Driver returns the driver as string
func (e *Engine) Driver() string {
	return e.driver
}

// Dsn returns the connection dsn
func (e *Engine) Dsn() string {
	return e.dsn
}
{'fraction_non_alphanumeric': 0.12463199214916584, 'fraction_numerical': 0.0, 'mean_word_length': 3.2302904564315353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2420164', 'n_tokens_mistral': 751, 'n_tokens_neox': 720, 'n_words': 263}