我目前正在尝试在Node.js环境中使用Cassandra,但我不了解。

当我运行代码时,执行查询后,脚本不会退出,仍在我的终端上运行。

这是我正在使用的代码:



const cassandra = require('cassandra-driver');
const databaseConfig = require('./config/database.json');

const authProvider = new cassandra.auth.PlainTextAuthProvider(databaseConfig.cassandra.username, databaseConfig.cassandra.password);

const db = new cassandra.Client({
    contactPoints: databaseConfig.cassandra.contactPoints,
    authProvider: authProvider
});

db.execute("INSERT INTO my_keyspace.my_table (id, year, value, country) VALUES (now(), 2010, 100.000, 'TUNISIE');", function(err, result){
    if (err){
        console.log(err);
    }
    else {
       console.log("azeaea")
    }
});





这是我得到的输出
node.js - cassandra继续执行-LMLPHP

请求结束后,我的脚本在终端上继续运行是正常的吗(因为我没有关闭查询或错过了其他地方)?

最佳答案

您需要关闭数据库上的连接,否则脚本将等待其他请求。

祝你有美好的一天,

关于node.js - cassandra继续执行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53282998/

10-11 22:29
查看更多