Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Execution not working on docker scylla #299

Open
sujit-baniya opened this issue Oct 13, 2022 · 0 comments
Open

Query Execution not working on docker scylla #299

sujit-baniya opened this issue Oct 13, 2022 · 0 comments

Comments

@sujit-baniya
Copy link

Platform: Linux (Docker)
App Language: Golang (non-Docker)
I'm trying to use this driver for operations but got stuck on error

panic: node &{[220 47 239 56 226 129 69 100 158 115 200 137 86 16 55 196] 172.21.0.2 datacenter1 rack1 <nil> {[] {[] 0}}} is down

Code:

package main

import (
	"context"
	"fmt"

	"github.com/scylladb/scylla-go-driver"
)

func main() {
	var Keyspace = "go_demo1"
// 	var Port = 9042
	var Host = "127.0.0.1"
	ctx := context.Background()
	cfg := scylla.DefaultSessionConfig(Keyspace, []string{Host}...)
	session, err := scylla.NewSession(ctx, cfg)
	if err != nil {
		panic(err)
	}
	defer session.Close()
	stmts := []string{
		"CREATE KEYSPACE IF NOT EXISTS go_demo1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}",
		"CREATE TABLE IF NOT EXISTS go_demo1.users (user_id int, fname text, lname text, PRIMARY KEY((user_id)))",
		"INSERT INTO go_demo1.users(user_id, fname, lname) VALUES (1, 'rick', 'sanchez')",
		"INSERT INTO go_demo1.users(user_id, fname, lname) VALUES (4, 'rust', 'cohle')",
	}

	for _, stmt := range stmts {
		q := session.Query(stmt)
		if _, err := q.Exec(ctx); err != nil {
			panic(err.Error())
		}
	}

	q := session.Query("SELECT * FROM go_demo1.users")

	res, err := q.Exec(ctx)
	if err != nil {
		panic(err)
	}

	for _, row := range res.Rows {
		pk, err := row[0].AsInt32()
		if err != nil {
			panic(err)
		}
		name, err := row[1].AsText()
		if err != nil {
			panic(err)
		}
		surname, err := row[2].AsText()
		if err != nil {
			panic(err)
		}
		fmt.Println(pk, name, surname)
	}
}

The driver is not respecting the exported port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant