Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
插入错误:SQLITE\u错误:没有这样的表:注释_Sql_Node.js_Sqlite - Fatal编程技术网

插入错误:SQLITE\u错误:没有这样的表:注释

插入错误:SQLITE\u错误:没有这样的表:注释,sql,node.js,sqlite,Sql,Node.js,Sqlite,我正在为我自己开发的项目设置一个服务器,并分别使用SQLite和Node.js作为数据库类型和服务器平台。我对后端开发相对较新,我正在尝试设置一个从网页前端到后端的POST请求,以便用户提交的任何内容都将存储在“comments.db”中,服务器中的一个文件将存储所有用户名和数据(特别是用户ID和数据) 在过去,我尝试以不同的方式重命名数据库,并将数据库移动到几个不同的子文件中,但在提交时总是产生相同的错误 以下是我的node.js文件的代码: var os = require( 'os' );

我正在为我自己开发的项目设置一个服务器,并分别使用SQLite和Node.js作为数据库类型和服务器平台。我对后端开发相对较新,我正在尝试设置一个从网页前端到后端的POST请求,以便用户提交的任何内容都将存储在“comments.db”中,服务器中的一个文件将存储所有用户名和数据(特别是用户ID和数据)

在过去,我尝试以不同的方式重命名数据库,并将数据库移动到几个不同的子文件中,但在提交时总是产生相同的错误

以下是我的node.js文件的代码:

var os = require( 'os' );

const interfaces = os.networkInterfaces();
 const addresses = [];
 var getMacAddress;



var request = require('request');
var express = require('express');
var sqlite3 = require('sqlite3');
var bodyParser = require('body-parser');


var ip = require("ip");
var address = ip.address();
var db = new sqlite3.Database('comments.db');
var app = express();

app.use(express.static(__dirname));
app.use(bodyParser.urlencoded({extended: false}));

app.get('/comments', function(request, response){
    // response.send('Hello Worlds');
    response.send("Hello my name is aestheticnoodle and you have reached a wrong");
});



app.get('/comments', function(request, response){
    console.log('GET request received at /alpha');
    db.all('SELECT * FROM comments', function(err, rows){
        if(err){
            console.log("Error");
        } else {
            response.send(rows);
            //pass rows back to the client
        }
    });
}); 


//runs once a user submits a comment
app.post('/comments', function(request, response){
    db.run('INSERT INTO comments VALUES (?, ?)', ["aestheticnoodle" ,request.body.action], function(err, rows){
        if(err){
            console.log(request.body.action);
            console.log("INSERT INTO " + err);
        } else {
            response.status(200).redirect('chat.html');
        }
    });
});

app.listen(3000, function(){
    console.log("Server is running on port 3000");
});

var admin = require("firebase-admin");


var firebaseConfig = {
    apiKey: "baseapp",
    authDomain: "fire",
    databaseURL: "inthe,
    projectId: "data",
    storageBucket: "",
    messagingSenderId: "private",
    appId: "some2"
  };
  admin.initializeApp(firebaseConfig);



var headers = {
    'App-Id': 'someappid',
    'App-Key': 'someappkey',
    'Content-Type': 'application/json'
};

var dataString = '{"text": "test run.."}';

var options = {
    url: 'https://somesite.com/v2/parse',
    method: 'POST',
    headers: headers,
    body: dataString
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);
误差如下:

C:\Users\achu1\Music\projectsummer2019\cybeRx>node nodeRequest.js
Server is running on port 3000
undefined
INSERT INTO Error: SQLITE_ERROR: no such table: comments
下面是javascript代码片段,我尝试在聊天机器人的界面中插入html:

var string = "What seems to be the problem you have been experiencing? Use one of the keywords, per <a href = \"symptomlist.html\"  target=\"_blank\"> SymptomList</a> the complete list of symptoms."
        document.getElementById("chat").innerHTML += '<form action = "/comments" method = "POST">'+ "<div id = \"botLog\" class = \"chatting\">" + string + '<textarea rows = "15" name = "comment"> Write stuff here' + '</textarea>'+ '<br><br><input type = "submit" value = "SUBMIT"/></form>' + "</div><br>";
var string=“您遇到的问题似乎是什么?请根据症状的完整列表使用其中一个关键字。”
document.getElementById(“chat”).innerHTML++=''++''+字符串+'在这里写东西'++'++'

'+'
“;
如您所见,我试图通过在我的
comment.db
文件中创建
POST
方法表单来连接我的数据库和运行在
localhost
中的html文件,该文件实际上位于我的目录中

为什么节点会说没有这样的数据库来执行
POST
命令,我如何解决这个问题以便将文本框数据保存到数据库中