biokoda / actordb

ActorDB distributed SQL database
Mozilla Public License 2.0
1.9k stars 71 forks source link

Golang mysql package #6

Closed mpdroog closed 9 years ago

mpdroog commented 9 years ago

Hi all,

I seem to have trouble getting my Go code working with ActorDB. It returns {error,no_actor_defined} when requesting a connection.

Go code

package main

import (
    "fmt"
    "database/sql"
    _ "github.com/go-sql-driver/mysql"
)
func main() {
    DB, e := sql.Open("mysql", ":@(127.0.0.1:33307)/")
    if e != nil {
        panic(e)
    }
    if e := DB.Ping(); e != nil {
        panic(e) // Line 14 where it crashes
    }
    if _, e := DB.Exec("ACTOR type1(payments) CREATE"); e != nil {
        panic(e)
    }
    fmt.Println("Success!")
}

Crash report

panic: Error 1: Error-Id: "0d47f0b2-48fa-26b3-2092-397287fe620e"
Exception: {error,no_actor_defined} 

goroutine 1 [running]:
main.main()
    .../main.go:14 +0xe7

goroutine 5 [chan receive]:
database/sql.(*DB).connectionOpener(0xc208054780)
    /usr/local/go/src/database/sql/sql.go:589 +0x4c
created by database/sql.Open
    /usr/local/go/src/database/sql/sql.go:452 +0x31c

I can image you guy's don't write in Go everyday so I was hoping you could hint me how I can see where it goes wrong from the actordb side of things?

SergejJurecko commented 9 years ago

"ACTOR type1(payments) CREATE" is a useless statement by itself. It just tells actordb where to go. Execute a select/insert/update after it like so:

"ACTOR type1(payments) CREATE; INSERT into ....;"

SergejJurecko commented 9 years ago

Or you can use thrift to generate a connector to ActorDB.

https://github.com/biokoda/actordb_thrift/blob/0.9pre9/adbt.thrift

SergejJurecko commented 9 years ago

Sorry I missed that you call Ping. Why not just ignore the error? If the purpose of ping is to check if connection to DB is still open, getting back that error means you are. The connection is still completely usable, at least form the ActorDB side.

mpdroog commented 9 years ago

Thnx for the advice and quick response, I'll be looking into it.

mpdroog commented 9 years ago

Okay ignored the error with ping, got the same error again after firing a query like: ACTOR type1(payments) CREATE; SELECT * FROM a So I guess the mysql/database library in Go isn't compatible.

Also did a look at Thrift, but the Go example feels very complex.

Thanks for the help but I'll be looking at other databases for solving my problem.