How to insert data with On Conflict it will replace in sqlite

Viewed 107

I have facing an issue while running sql query for bulk Insert and while inserting it was throwing an error that SQLITE_ERROR: near "ON": syntax error

I am using sqlite3: 3.22.0 version

and my DLL file was look like

CREATE TABLE myTable (
    id               INTEGER     PRIMARY KEY,
    sessionId        INTEGER     REFERENCES sessions (sessionid),
    name             String
    UNIQUE (
        sessionId,
        name
    )
    ON CONFLICT REPLACE
);

Inserting bulk data on single query through sequelize.

My code is ..

db.myTable.bulkCreate(tableData).then(function(data) { 
     if(data){
        res.json({success: true});
     }
}, function(err) {  
      res.json({ success: false, msg: "Error while importing session"});
})

Here on above code the tableData have the array of data to be inserted.

while running this bulk insert it was showing SQLITE_ERROR: near "ON": syntax error error!!

0 Answers
Related