Symisc UnQLite

An Embeddable NoSQL Database Engine

UnQLite C/C++ API Reference - Delete Database Record.


int unqlite_kv_delete(unqlite *pDb,const void *pKey,int nKeyLen);

Remove a record from the database.


To remove a particular record from the database, you can use this high-level thread-safe routine to perform the deletion. You can also delete records using cursors via unqlite_kv_cursor_delete_entry().



A pointer to a unQLite Database Handle.

Target record key.

pKey length. If the nKeyLen argument is less than zero, then pKey is read up to the first zero terminator. If nKeyLen is non-negative, then it is the maximum number of bytes read from pKey.

Return value

UNQLITE_OK is returned on success. Any other return value indicates failure such as:

UNQLITE_NOTFOUND: Nonexistent record.

UNQLITE_BUSY: Another thread or process have a reserved or exclusive lock on the database. In which case, the caller should wait until the lock holder relinquish it.

UNQLITE_READ_ONLY: Read-only Key/Value storage engine.

UNQLITE_NOTIMPLEMENTED: The underlying KV storage engine does not implement the delete operation.

UNQLITE_PERM: Permission error.

UNQLITE_LIMIT: Journal file record limit reached (An unlikely scenario).

UNQLITE_IOERR: OS specific error. This error is considered harmful and you should perform an immediate rollback via unqlite_rollback().

UNQLITE_NOMEM: Out of memory (Unlikely scenario). This error is considered harmful and you should perform an immediate rollback via unqlite_rollback().

For a human-readable error message, you can extract the database error log via unqlite_config() with a configuration verb set to UNQLITE_CONFIG_ERR_LOG.


int rc;
unqlite *pDb;

// Open our database;
rc = unqlite_open(&pDb,"test.db",UNQLITE_OPEN_READWRITE);
if( rc != UNQLITE_OK ){ return; }

//Store some records unqlite_kv_append, unqlite_kv_store...

//Delete a record

rc = unqlite_kv_delete(pDb,"SomeRecord",-1);

if( rc != UNQLITE_OK ){

  const char *zBuf;

  int iLen;

  /* Extract database error log */


  if( iLen > 0 ){



  if( rc != UNQLITE_BUSY && rc != UNQLITE_NOTFOUND ){

    /* Rollback */



//Auto-commit the transaction and close our handle

See also

unqlite_kv_fetch, unqlite_kv_fetch_callback, unqlite_kv_append, unqlite_kv_store, unqlite_open, unqlite_close, unqlite_config.

Symisc Systems
Copyright © Symisc Systems