<commit_before>package store

import (
	"context"
	"database/sql"

	"github.com/jbub/pgbouncer_exporter/internal/domain"

	"github.com/jmoiron/sqlx"
)

type stat struct {
	Database          string `db:"database"`
	TotalRequests     int64  `db:"total_requests"`
	TotalReceived     int64  `db:"total_received"`
	TotalSent         int64  `db:"total_sent"`
	TotalQueryTime    int64  `db:"total_query_time"`
	TotalXactCount    int64  `db:"total_xact_count"`
	TotalXactTime     int64  `db:"total_xact_time"`
	TotalQueryCount   int64  `db:"total_query_count"`
	TotalWaitTime     int64  `db:"total_wait_time"`
	AverageRequests   int64  `db:"avg_req"`
	AverageReceived   int64  `db:"avg_recv"`
	AverageSent       int64  `db:"avg_sent"`
	AverageQuery      int64  `db:"avg_query"`
	AverageQueryCount int64  `db:"avg_query_count"`
	AverageQueryTime  int64  `db:"avg_query_time"`
	AverageXactTime   int64  `db:"avg_xact_time"`
	AverageXactCount  int64  `db:"avg_xact_count"`
	AverageWaitTime   int64  `db:"avg_wait_time"`
}

type pool struct {
	Database     string         `db:"database"`
	User         string         `db:"user"`
	Active       int64          `db:"cl_active"`
	Waiting      int64          `db:"cl_waiting"`
	ServerActive int64          `db:"sv_active"`
	ServerIdle   int64          `db:"sv_idle"`
	ServerUsed   int64          `db:"sv_used"`
	ServerTested int64          `db:"sv_tested"`
	ServerLogin  int64          `db:"sv_login"`
	MaxWait      int64          `db:"maxwait"`
	MaxWaitUs    int64          `db:"maxwait_us"`
	PoolMode     sql.NullString `db:"pool_mode"`
}

type database struct {
	Name               string         `db:"name"`
	Host               sql.NullString `db:"host"`
	Port               int64          `db:"port"`
	Database           string         `db:"database"`
	ForceUser          sql.NullString `db:"force_user"`
	PoolSize           int64          `db:"pool_size"`
	ReservePool        int64          `db:"reserve_pool"`
	PoolMode           sql.NullString `db:"pool_mode"`
	MaxConnections     int64          `db:"max_connections"`
	CurrentConnections int64          `db:"current_connections"`
	Paused             int64          `db:"paused"`
	Disabled           int64          `db:"disabled"`
}

type list struct {
	List  string `db:"list"`
	Items int64  `db:"items"`
}

// NewSQLStore returns new SQLStore.
func NewSQLStore(dataSource string) (*SQLStore, error) {
	db, err := sqlx.Connect("postgres", dataSource)
	if err != nil {<commit_msg>Use sqlx.Open instead of sqlx.Connect to skip calling Ping.<commit_after>package store

import (
	"context"
	"database/sql"

	"github.com/jbub/pgbouncer_exporter/internal/domain"

	"github.com/jmoiron/sqlx"
)

type stat struct {
	Database          string `db:"database"`
	TotalRequests     int64  `db:"total_requests"`
	TotalReceived     int64  `db:"total_received"`
	TotalSent         int64  `db:"total_sent"`
	TotalQueryTime    int64  `db:"total_query_time"`
	TotalXactCount    int64  `db:"total_xact_count"`
	TotalXactTime     int64  `db:"total_xact_time"`
	TotalQueryCount   int64  `db:"total_query_count"`
	TotalWaitTime     int64  `db:"total_wait_time"`
	AverageRequests   int64  `db:"avg_req"`
	AverageReceived   int64  `db:"avg_recv"`
	AverageSent       int64  `db:"avg_sent"`
	AverageQuery      int64  `db:"avg_query"`
	AverageQueryCount int64  `db:"avg_query_count"`
	AverageQueryTime  int64  `db:"avg_query_time"`
	AverageXactTime   int64  `db:"avg_xact_time"`
	AverageXactCount  int64  `db:"avg_xact_count"`
	AverageWaitTime   int64  `db:"avg_wait_time"`
}

type pool struct {
	Database     string         `db:"database"`
	User         string         `db:"user"`
	Active       int64          `db:"cl_active"`
	Waiting      int64          `db:"cl_waiting"`
	ServerActive int64          `db:"sv_active"`
	ServerIdle   int64          `db:"sv_idle"`
	ServerUsed   int64          `db:"sv_used"`
	ServerTested int64          `db:"sv_tested"`
	ServerLogin  int64          `db:"sv_login"`
	MaxWait      int64          `db:"maxwait"`
	MaxWaitUs    int64          `db:"maxwait_us"`
	PoolMode     sql.NullString `db:"pool_mode"`
}

type database struct {
	Name               string         `db:"name"`
	Host               sql.NullString `db:"host"`
	Port               int64          `db:"port"`
	Database           string         `db:"database"`
	ForceUser          sql.NullString `db:"force_user"`
	PoolSize           int64          `db:"pool_size"`
	ReservePool        int64          `db:"reserve_pool"`
	PoolMode           sql.NullString `db:"pool_mode"`
	MaxConnections     int64          `db:"max_connections"`
	CurrentConnections int64          `db:"current_connections"`
	Paused             int64          `db:"paused"`
	Disabled           int64          `db:"disabled"`
}

type list struct {
	List  string `db:"list"`
	Items int64  `db:"items"`
}

// NewSQLStore returns new SQLStore.
func NewSQLStore(dataSource string) (*SQLStore, error) {
	db, err := sqlx.Open("postgres", dataSource)
	if err != nil {
{'fraction_non_alphanumeric': 0.11133400200601805, 'fraction_numerical': 0.02728184553660983, 'mean_word_length': 2.7043090638930165, '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': '5285844', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1647, 'n_words': 342}