Thursday, 11 May 2017

Sqlite3 delete by primary key

I am using Node with node-sqlite3. I cannot seem to delete rows by passing their primary key, but I can delete rows by passing some other column value.

Example

    this.db.run("DELETE FROM MyTable WHERE Name = 'Bob'");

No problem. But:

    this.db.run("DELETE FROM MyTable WHERE _id = 3);

I have specified _id as my autoincrement / primary key. I can prove this by doing a PRAGMA and showing the debugger's results here, which clearly indicates _id as the pk

PRAGMA call

enter image description here

Debugger

enter image description here

I really don't know what to do as I get no errors from the db.run call



via jozenbasin

No comments:

Post a Comment