GithubHelp home page GithubHelp logo

Comments (5)

slvrtrn avatar slvrtrn commented on June 29, 2024 1

DBeaver has native ClickHouse support via the official JDBC driver — why would you use the MySQL interface for that? The same is true for DataGrip.

Regarding the intended use case, our primary focus was on the (proprietary) BI tools that don't have a native plugin or driver, such as:

  • Looker Studio
  • Tableau Online
  • QuickSight

When possible, using native drivers is always preferred.

from clickhouse.

nikitamikhaylov avatar nikitamikhaylov commented on June 29, 2024

Please provide the full reproducer (the whole Go program) and step-by-step guidance how to get this error. This will simplify the work for developers and increase chances for it to be fixed quickly.

from clickhouse.

olegkv avatar olegkv commented on June 29, 2024

ch-test.zip
attached sample Go program
Just run it in debugger and see the error when query "select 1" is run

from clickhouse.

slvrtrn avatar slvrtrn commented on June 29, 2024

The MySQL interface is mainly for specific tools that don't have native ClickHouse support yet. We also have the official ClickHouse Go driver available (clickhouse-go).

In any case, if you grab the Let's Encrypt root cert, the following will work:

package main

import (
	"context"
	"crypto/tls"
	"crypto/x509"
	"database/sql"
	"fmt"
	"log"
	"os"

	"github.com/go-sql-driver/mysql"
)
func main() {
	ctx := context.Background()

	rootCertPool := x509.NewCertPool()
	pem, err := os.ReadFile("./isrgrootx1.pem")
	if err != nil {
		panic(err)
	}
	if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
		log.Fatal("Failed to append PEM.")
	}
	err = mysql.RegisterTLSConfig("custom", &tls.Config{
		ServerName: "<service>.clickhouse.cloud",
		RootCAs:    rootCertPool,
	})
	if err != nil {
		panic(err)
	}

	db, err := sql.Open("mysql", "<username>:<password>@tcp(<service>.clickhouse.cloud:3306)/default?tls=custom")
	if err != nil {
		panic(err)
	}

	conn, _ := db.Conn(ctx)
	var result string
	err = conn.QueryRowContext(ctx, `SELECT version() AS result`).Scan(&result)
	if err != nil {
		panic(err)
	}
	fmt.Printf("result: %s\n", result)
}

Which prints the correct result for my test instance:

result: 24.1.2.10900

Don't forget to allow the instance access for your IP address; otherwise, you might encounter the same EOF error again.

from clickhouse.

olegkv avatar olegkv commented on June 29, 2024

Hi guys
I thought that ClickHouse MySQL interface was intended to allow existing apps which use MySQL to use ClickHouse as drop-in replacement - just switch to new address, assuming that table structures are the same and SQL queries are compatible.
That is not the case?
ClickHouse documentation says:
"ClickHouse supports the MySQL wire protocol. This allow tools that are MySQL-compatible to interact with ClickHouse seamlessly"
I thought that means all apps which use MySQL? If that is not the case, please clarify.
Also, another example, I cannot connect to ClickHouse's MySQL port using DBeaver in same way as I connect to real MySQL database - is that expected behavior?
Thanks!

from clickhouse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.