Ejemplo n.º 1
0
func extractConfig() pgx.ConnConfig {
	var config pgx.ConnConfig
	config.Host = DBHost
	config.Database = DBName

	return config
}
Ejemplo n.º 2
0
func extractConfig() pgx.ConnConfig {
	var config pgx.ConnConfig

	config.Host = "localhost"

	return config
}
func extractConfig() pgx.ConnConfig {
	var config pgx.ConnConfig

	config.Host = "localhost"
	config.User = "******"
	config.Password = "******"
	config.Database = "yourdatabase"

	return config
}
Ejemplo n.º 4
0
func extractPGXStorageConfig(c models.StorageSettings) pgx.ConnConfig {
	var config pgx.ConnConfig

	config.Host = c.Host
	config.User = c.User
	config.Password = c.Password
	config.Database = c.Database
	config.Logger = databaseLogger{}
	config.LogLevel = pgx.LogLevelError

	return config
}
Ejemplo n.º 5
0
Archivo: main.go Proyecto: jackc/tpr
func newPool(conf ini.File, logger log.Logger) (*pgx.ConnPool, error) {
	logger = logger.New("module", "pgx")
	if level, ok := conf.Get("log", "pgx_level"); ok {
		setFilterHandler(level, logger, log.StdoutHandler)
	}

	connConfig := pgx.ConnConfig{Logger: logger}

	connConfig.Host, _ = conf.Get("database", "host")
	if connConfig.Host == "" {
		return nil, errors.New("Config must contain database.host but it does not")
	}

	if p, ok := conf.Get("database", "port"); ok {
		n, err := strconv.ParseUint(p, 10, 16)
		connConfig.Port = uint16(n)
		if err != nil {
			return nil, err
		}
	}

	var ok bool

	if connConfig.Database, ok = conf.Get("database", "database"); !ok {
		return nil, errors.New("Config must contain database.database but it does not")
	}
	connConfig.User, _ = conf.Get("database", "user")
	connConfig.Password, _ = conf.Get("database", "password")

	poolConfig := pgx.ConnPoolConfig{
		ConnConfig:     connConfig,
		MaxConnections: 10,
	}

	return pgx.NewConnPool(poolConfig)
}
Ejemplo n.º 6
0
func extractConfig() pgx.ConnConfig {
	var config pgx.ConnConfig

	config.Host = os.Getenv("TODO_DB_HOST")
	if config.Host == "" {
		config.Host = "localhost"
	}

	config.User = os.Getenv("TODO_DB_USER")
	if config.User == "" {
		config.User = os.Getenv("USER")
	}

	config.Password = os.Getenv("TODO_DB_PASSWORD")

	config.Database = os.Getenv("TODO_DB_DATABASE")
	if config.Database == "" {
		config.Database = "todo"
	}

	return config
}