func CreateDBIfNotExists(dbName string) error {
	return ConnectAndExecute(DBConnURI(""), func(pg *sql.DB) error {
		rows, err := pg.Query("SELECT 1 from pg_database WHERE datname = $1 LIMIT 1", dbName)
		if err != nil {
			return err
		}
		defer rows.Close()
		if !rows.Next() {
			if err := rows.Err(); err != nil {
				return err
			}
			log.Printf("Test database %q does not exist, creating.", dbName)
			if _, err := pg.Exec(fmt.Sprintf("CREATE DATABASE %q;", dbName)); err != nil {
				return fmt.Errorf("error creating %q: %v", dbName, err)
			}
		}
		return nil
	})
}
// CreateDBIfNotExists checks whether the given dbName is an existing database,
// and creates one if not.
CreateDBIfNotExists checks whether the given dbName is an existing database,
and creates one if not.
// CreateDBIfNotExists checks whether the given dbName is an existing database // and creates one if not .
func CreateDBIfNotExists(dbName string) error {
	return ConnectAndExecute(DBConnURI(""), func(pg *sql.DB) error {
		rows, err := pg.Query("SELECT 1 from pg_database WHERE datname = $1 LIMIT 1", dbName)
		if err != nil {
			return err
		}
		defer rows.Close()
		if !rows.Next() {
			if err := rows.Err(); err != nil {
				return err
			}
			log.Printf("Test database %q does not exist, creating.", dbName)
			if _, err := pg.Exec(fmt.Sprintf("CREATE DATABASE %q;", dbName)); err != nil {
				return fmt.Errorf("error creating %q: %v", dbName, err)
			}
		}
		return nil
	})
}
func CreateDBIfNotExists ( dbName string ) error { return ConnectAndExecute ( DBConnURI ( " " ) , func ( pg * sql . DB ) error { rows , err := pg . Query ( " " , dbName ) if err != nil { return err } defer rows . Close ( ) if ! rows . Next ( ) { if err := rows . Err ( ) ; err != nil { return err } log . Printf ( " " , dbName ) if _ , err := pg . Exec ( fmt . Sprintf ( " " , dbName ) ) ; err != nil { return fmt . Errorf ( " " , dbName , err ) } } return nil } ) }
CreateDBIfNotExists checks whether the given dbName is an existing database,
and creates one if not.
CreateDBIfNotExists checks whether the given dbName is an existing database and creates one if not .