3

As per this Github issue, the Postgres backend feature for the Cayley graph database is implemented. However, currently there aren't examples in the docs, and I couldn't figure it out by reading the code. Could someone help?

Edit

To start playing with Cayley, we can load data that comes with the source with the following command:

./cayley load --config=cayley.cfg.overview --quads=data/30kmoviedata.nq.gz

I tried two variations of the cayley.cfg.overview file:

{
    "database": "sql",
    "db_path": "localhost:5432",
    "read_only": false
}

and

{
    "database": "sql",
    "db_path": "/var/lib/postgresql/9.4/main/cayley",
    "read_only": false
}

The first one being analogous to the one used with mongo (5432 being the port at which the postgres server is listening). As for the second one, I have no clue of what I'm doing there :D.

In any case, when I use the ./cayley load --config=cayley.cfg.overview --quads=data/30kmoviedata.nq.gz command I get the following error (varying only the value of db_path):

Couldn't open database at localhost:5432: 
&errors.errorString{s:"missing \"=\" after \"127.0.0.1:5432\" in connection 
info string\""}
E1117 21:09:18.300033 16689 cayley.go:277] missing "=" after "localhost:5432" 
in connection info string"
  • Can you post what you have now and provide more specific information about what error you're facing? It might be more constructive to pose each specific error as a question since configuring a system can be pretty open ended (ie you're stuck on error A and resolve it to find error B and then get error C and so on). – evanmcdonnal Nov 18 '15 at 00:30
  • @evanmcdonnal I provided more detail. – Marcus Vinícius Monteiro Nov 18 '15 at 00:59
  • Can you try using your `localhost:5432` config but with `"database":"mongo"` ? In most examples the value is `leveldb` in the docs one of the values is `mongo`, however there is no `sql` value as far as I can tell. In between my other work I'll track down that file (`caylay.go`) and see what's going on there because the error would indicate there should be a trailing equals but I don't see any examples that have anything remotely similar (not like it's a sql connection string and has credentials ect after that). – evanmcdonnal Nov 18 '15 at 02:05
  • Found part of what I'm looking for. You're failing in here, the call to `Load` returns that error https://github.com/google/cayley/blob/master/cmd/cayley/cayley.go#L209 – evanmcdonnal Nov 18 '15 at 02:08
  • @evanmcdonnal using config with `"database": "mongo"` if for using with a mongodb backend. There is a `sql` value for `database` (see [source](https://github.com/google/cayley/blob/master/graph/sql/quadstore.go)), however it isn't documented, and I haven't been able to figure it out yet. – Marcus Vinícius Monteiro Nov 18 '15 at 02:12
  • Well that answer seems like it might have some promise. I just suggested using `mongo` because you said your connection string was analogous to it. – evanmcdonnal Nov 18 '15 at 02:19
  • @evanmcdonnal yes, I'll check that that answer out. – Marcus Vinícius Monteiro Nov 18 '15 at 02:23

1 Answers1

3

It looks like Cayley is using lib/pq under the covers. lib/pq connection strings look something like this: "user=pqgotest dbname=pqgotest sslmode=verify-full" or "postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full" For full details see the lib/pq documentation at godoc.org.

(You can see where the sql.Open call is made in cayley/graph/sql/quadstore.go connectSQLTables.)

Dmitri Goldring
  • 4,176
  • 2
  • 24
  • 28
  • 1
    I got it after checking the godocs, thanks! After that, I ran into an error that said that `db: failed to load data: pq: relation "quads" does not exist`, which I got around by creating a table `quads` according to the query found at https://github.com/google/cayley/blob/master/graph/sql/quadstore.go. After that, I managed to load the data. – Marcus Vinícius Monteiro Nov 18 '15 at 02:39