“Insert if not exists” statement in SQLite

If you never want to have duplicates, you should declare this as a table constraint: CREATE TABLE bookmarks( users_id INTEGER, lessoninfo_id INTEGER, UNIQUE(users_id, lessoninfo_id) ); (A primary key over both columns would have the same effect.) It is then possible to tell the database that you want to silently ignore records that would violate such … Read more

Creating stored procedure and SQLite?

SQLite has had to sacrifice other characteristics that some people find useful, such as high concurrency, fine-grained access control, a rich set of built-in functions, stored procedures, esoteric SQL language features, XML and/or Java extensions, tera- or peta-byte scalability, and so forth Source : Appropriate Uses For SQLite

SQLite Concurrent Access

If most of those concurrent accesses are reads (e.g. SELECT), SQLite can handle them very well. But if you start writing concurrently, lock contention could become an issue. A lot would then depend on how fast your filesystem is, since the SQLite engine itself is extremely fast and has many clever optimizations to minimize contention. … Read more

How do I unlock a SQLite database?

In windows you can try this program http://www.nirsoft.net/utils/opened_files_view.html to find out the process is handling db file. Try closed that program for unlock database In Linux and macOS you can do something similar, for example, if your locked file is development.db: $ fuser development.db This command will show what process is locking the file: > … Read more

How to delete or add column in SQLITE?

ALTER TABLE SQLite SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. It is not possible to rename a column, remove a column, or add or remove constraints from a table. You can: … Read more

INSERT IF NOT EXISTS ELSE UPDATE?

Have a look at http://sqlite.org/lang_conflict.html. You want something like: insert or replace into Book (ID, Name, TypeID, Level, Seen) values ((select ID from Book where Name = “SearchName”), “SearchName”, …); Note that any field not in the insert list will be set to NULL if the row already exists in the table. This is why … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)