I use docker, cockroachdb v1.0.1
and this code:
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/lib/pq"
)
func main() {
// Connect to the "bank" database.
db, err := sql.Open("postgres", "postgresql://maxroach@localhost:26257/bank?sslmode=disable")
if err != nil {
log.Fatal("error connecting to the database: ", err)
}
tx, err := db.Begin()
if err != nil {
log.Fatal("error creating transation: ", err)
}
// Create the "accounts" table.
if _, err := tx.Exec(
"CREATE TABLE IF NOT EXISTS accounts (id INT PRIMARY KEY, balance INT)"); err != nil {
log.Fatal(err)
}
// Insert two rows into the "accounts" table.
if _, err := tx.Exec(
"INSERT INTO accounts (id, balance) VALUES (1, 1000), (2, 250)"); err != nil {
log.Fatal(err)
}
tx.Commit()
// Print out the balances.
rows, err := db.Query("SELECT id, balance FROM accounts")
if err != nil {
log.Fatal(err)
}
defer rows.Close()
fmt.Println("Initial balances:")
for rows.Next() {
var id, balance int
if err := rows.Scan(&id, &balance); err != nil {
log.Fatal(err)
}
fmt.Printf("%d %d\n", id, balance)
}
}
I get this error
$ go run main.go
2017/06/07 11:58:10 error creating transation: pq: syntax error at or near "read"
BEGIN READ WRITE
^
exit status 1
It started recently, it was working before, any idea?