<commit_before>package mdq

import (
	"database/sql"
	"fmt"
)

type Executor interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

type Result struct {
	Database string
	Columns  []string
	Rows     []map[string]interface{}
}

type column struct {
	value interface{}
}

func (c *column) Scan(src interface{}) error {
	c.value = src
	if bs, ok := src.([]byte); ok {
		c.value = string(bs)
	}
	return nil
}

type DB interface {
	Query(query string) (Result, error)
}

func NewDB(name, driver, dsn string) (DB, error) {
	con, err := sql.Open(driver, dsn)
	if err != nil {
		return nil, err
	}
	return db{name, con}, nil
}

type db struct {
	name     string
	executor Executor
}

func (db db) Query(query string) (Result, error) {
	rows, err := db.executor.Query(query)
	if err != nil {
		return Result{}, db.err(err, "execution failed")
	}

	columns, err := rows.Columns()
	if err != nil {
		return Result{}, db.err(err, "failed to fetch column name")
	}
	columnSize := len(columns)
<commit_msg>Close rows<commit_after>package mdq

import (
	"database/sql"
	"fmt"
)

type Executor interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

type Result struct {
	Database string
	Columns  []string
	Rows     []map[string]interface{}
}

type column struct {
	value interface{}
}

func (c *column) Scan(src interface{}) error {
	c.value = src
	if bs, ok := src.([]byte); ok {
		c.value = string(bs)
	}
	return nil
}

type DB interface {
	Query(query string) (Result, error)
}

func NewDB(name, driver, dsn string) (DB, error) {
	con, err := sql.Open(driver, dsn)
	if err != nil {
		return nil, err
	}
	return db{name, con}, nil
}

type db struct {
	name     string
	executor Executor
}

func (db db) Query(query string) (Result, error) {
	rows, err := db.executor.Query(query)
	if err != nil {
		return Result{}, db.err(err, "execution failed")
	}
	defer rows.Close()

	columns, err := rows.Columns()
	if err != nil {
		return Result{}, db.err(err, "failed to fetch column name")
	}
	columnSize := len(columns)

{'fraction_non_alphanumeric': 0.14831130690161526, 'fraction_numerical': 0.0, 'mean_word_length': 3.688073394495413, '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': '3116739', 'n_tokens_mistral': 747, 'n_tokens_neox': 730, 'n_words': 231}