SQLite Forum

Opening a DB with SQLITE_OPEN_EXCLUSIVE
Login
The SQLITE_OPEN_EXCLUSIVE flag is an internal-use-only flag in a
SQLite. The SQLite core will sometimes send that flag down
into the VFS in order to tell the VFS that it wants the open to fail if
the file already exists.  But it is not legal to pass the SQLITE_OPEN_EXCLUSIVE
flag into sqlite3_open().  That flag is silently masked off
[here][1].  

This fact is not well documented.  The only
hint that you, the reader, have is that if you look at the 
[documentation page for open flags][2], you will see the "VFS only"
comment after the SQLITE_OPEN_EXCLUSIVE definition.  This is,
admittedly, a feeble hint.  That part of the documentation could
use improvement.

[1]: src:/info/7a1b7017af16977b29?ln=3146
[2]: https://www.sqlite.org/c3ref/c_open_autoproxy.html

But the end analysis is that SQLite is currently performing as
designed and what you are asking for is an enhancement.
You want the ability to pass
in the SQLITE_OPEN_EXCLUSIVE flag and have it work like O_EXCL.
Probably this enhancement will also need a new extended return code:
SQLITE_CANTOPEN_EXISTS.

It seems like a reasonable request.  But we need to move cautiously
about these kinds of things.  So all I can say for now is
that we will look into it.