Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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
Node.js 将JSON对象插入SQLITE数据库_Node.js_Json_Sqlite_Insert - Fatal编程技术网

Node.js 将JSON对象插入SQLITE数据库

Node.js 将JSON对象插入SQLITE数据库,node.js,json,sqlite,insert,Node.js,Json,Sqlite,Insert,我正在尝试将一个json插入到一个SQLITE数据库中,该json包含我从cloud获得的许多值 我写了以下内容: var listUsers = await response.json(); //This is to pass to listUsers the response i get from the cloud //Here i remove unecessary fields listUsers.items.forEach(user=> {

我正在尝试将一个json插入到一个SQLITE数据库中,该json包含我从cloud获得的许多值

我写了以下内容:

var listUsers = await response.json(); //This is to pass to listUsers the response i get from the cloud
//Here i remove unecessary fields
        listUsers.items.forEach(user=> {
          delete(user.tenant)
          delete(user.user_admin)
          delete(user.user_owner)
          delete(user.update_date)
          console.log(user); //check what i get
          //Here the code that i guess helps me save the json to database
          db.serialize(() => {
          db.run(`INSERT INTO users VALUES`, JSON.stringify(user[![enter image description here][1]][1]));
          })  
          });
         } catch (error) {
           console.log(error);
         }
         };
下面是我想保存的示例(当然我有很多)

我试过这样的代码:

db.run(`INSERT INTO users VALUES`, { user });

但似乎什么都不管用我认为这是个错误:


你能帮帮我吗?我知道sqlite和json有json1,但无法使其工作,我尝试了db.push,但没有成功。。谢谢

有人在吗?我这样做了:db.prepare(“插入到用户(uid、名字、姓氏、出生性别、代码、出生日期)值(?、、?、?、?)”)。run(JSON.stringify(user)).finalize();我可以插入数据库,但它会将所有数据插入一个字段,我知道我就在附近,所以请帮助我。最后,多亏聊天组凯文的提示,我终于找到了答案。有人在吗?我这样做了:db.prepare(“插入到用户(uid、名字、姓氏、出生性别、代码、出生日期)值(?、、?、?、?)”)。run(JSON.stringify(user)).finalize();我可以插入数据库,但它会将所有数据插入一个字段,我知道我就在附近,所以请帮助我。最后,多亏了聊天组凯文的提示,我终于找到了答案
db.run(`INSERT INTO users VALUES(uid, first_name, last_name, birth_date, code, birthsex)`, patient);