Cassandra+nodejs: how to get the Keyspaces and Tables?
cassandra, node.js, nosql
Solution
`DESCRIBE` is a command only available on cqlsh tool.
Try querying system tables as it is described here.
Problem
I am trying to get the metadata, keyspaces, tables from a Cassandra Cluster. I am using the following node.js code: ``` var express = require('express'); var bodyParser = require('body-parser'); var cassandra = require('cassandra-driver'); var client = new cassandra.Client( { contactPoints : [ '127.0.0.1' ] } ); client.connect(function(err, result) { console.log('Connected To the Database.'); }); var app = express(); app.use(bodyParser.json()); app.set('json spaces', 2); app.get('/metadata', function(req, res) { res.send(client.hosts.slice(0).map(function (node) { return { address : node.address, rack : node.rack, datacenter : node.datacenter } })); }); app.get('/metadata/keyspaces', function(req, res) { client.execute("DESCRIBE KEYSPACES;", function(err, result) { if (err) { res.status(404).send(err); } else { res.json(result); } }); }); app.get('/metadata/tables', function(req, res) { client.execute("DESCRIBE TABLES", function(err, result) { if (err) { res.status(404).send({ msg : 'No Table found' }); } else { res.json(result); } }); }); var server = app.listen(3000, function() { console.log('Listening on port %d', server.address().port); }); ``` Problem is, when i run the above code, I do not get the existing keyspaces or tables from the database, Instead I get the following error: ``` { "name": "ResponseError", "message": "line 1:0 no viable alternative at input 'DESCRIBE'", "info": "Represents an error message from the server", "code": 8192, "query": "DESCRIBE KEYSPACES;" } ``` How can I see the these informations? Thank you in advance for help. UPDATE: I just came to know, DESCRIBE is a cqlsh command, so How I can solve in my case?