func getConnectString(workerNumber int) string {
	re := regexp.MustCompile(`(host|dbname|user)=\S*\b`)
	connectString := re.ReplaceAllString(postgresConnect, "")
	host := hostList[workerNumber%len(hostList)]
	connectString = fmt.Sprintf("host=%s dbname=%s user=%s %s", host, runner.DatabaseName(), user, connectString)
	if len(port) > 0 {
		connectString = fmt.Sprintf("%s port=%s", connectString, port)
	}
	if len(pass) > 0 {
		connectString = fmt.Sprintf("%s password=%s", connectString, pass)
	}
	if forceTextFormat {
		connectString = fmt.Sprintf("%s disable_prepared_binary_result=yes binary_parameters=no", connectString)
	}
	return connectString
}
Get the connection string for a connection to PostgreSQL.
If we're running queries against multiple nodes we need to balance the queries
across replicas. Each worker is assigned a sequence number -- we'll use that
to evenly distribute hosts to worker connections
package main
import (
	"database/sql"
	"encoding/json"
	"fmt"
	"regexp"
	"strings"
	"time"
	"github.com/blagojts/viper"
	_ "github.com/jackc/pgx/v4/stdlib"
	_ "github.com/lib/pq"
	"github.com/pkg/errors"
	"github.com/spf13/pflag"
	"github.com/timescale/tsbs/internal/utils"
	"github.com/timescale/tsbs/pkg/query"
)
const pgxDriver = "pgx"  
const pqDriver = "postgres"
var (
	postgresConnect string
	hostList        []string
	user            string
	pass            string
	port            string
	showExplain     bool
	forceTextFormat bool
)
var (
	runner *query.BenchmarkRunner
	driver string
)
func init() {
	var config query.BenchmarkRunnerConfig
	config.AddToFlagSet(pflag.CommandLine)
	pflag.String("postgres", "host=postgres user=postgres sslmode=disable",
		"String of additional PostgreSQL connection parameters, e.g., 'sslmode=disable'. Parameters for host and database will be ignored.")
	pflag.String("hosts", "localhost", "Comma separated list of PostgreSQL hosts (pass multiple values for sharding reads on a multi-node setup)")
	pflag.String("user", "postgres", "User to connect to PostgreSQL as")
	pflag.String("pass", "", "Password for the user connecting to PostgreSQL (leave blank if not password protected)")
	pflag.String("port", "5432", "Which port to connect to on the database host")
	pflag.Bool("show-explain", false, "Print out the EXPLAIN output for sample query")
	pflag.Bool("force-text-format", false, "Send/receive data in text format")
	pflag.Parse()
	err := utils.SetupConfigFile()
	if err != nil {
		panic(fmt.Errorf("fatal error config file: %s", err))
	}
	if err := viper.Unmarshal(&config); err != nil {
		panic(fmt.Errorf("unable to decode config: %s", err))
	}
	postgresConnect = viper.GetString("postgres")
	hosts := viper.GetString("hosts")
	user = viper.GetString("user")
	pass = viper.GetString("pass")
	port = viper.GetString("port")
	showExplain = viper.GetBool("show-explain")
	forceTextFormat = viper.GetBool("force-text-format")
	runner = query.NewBenchmarkRunner(config)
	if showExplain {
		runner.SetLimit(1)
	}
	if forceTextFormat {
		driver = pqDriver
	} else {
		driver = pgxDriver
	}
	for _, host := range strings.Split(hosts, ",") {
		hostList = append(hostList, host)
	}
}
func main() {
	runner.Run(&query.TimescaleDBPool, newProcessor)
}