-
Notifications
You must be signed in to change notification settings - Fork 33
How to open database with immutable flag? #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
hmmm I believe is either append |
I use sqlite.lua in neovim text editor using I tried append |
I just did a quick research and it seems to me that it's mostly likely a URI thing, see Recognized Query Parameters and URI filename examples section. I'm starting to believe that maybe open_v2 won't be needed and perhaps some internal url processing strips the query params.
Can you navigate to sqlite/defs, and run the following throw evaluating the file local uri = 'file:places.sqlite?immutable=1'
local opts = {}
local conn = M.get_new_db_ptr()
local code = clib.sqlite3_open(uri, conn)
if code ~= M.flags.ok then
error(("sqlite.lua: couldn't connect to sql database, ERR:"):format(code))
end
for k, v in pairs(opts) do
if not M.valid_pargma[k] then
error("sqlite.lua: " .. k .. " is not a valid pragma")
end
if type(k) == "boolean" then
k = "ON"
end
M.exec_stmt(conn[0], ("pragma %s = %s"):format(k, v))
end
vim.inspect(conn[0]) btw defs.lua is where ffi interface are. so if changes needs to made it will be made here. |
I tried to evaluate code you posted above. But I changed the uri to contain absolute path to sqlite db like:
Evaluation ended up on
To be precise I only defined function
|
Okay @Conni2461, informed me that perhaps open_uri need to be passed for this to work. Can you change the value of code to Also, to see errors change the body of M.get_err_msg = function(code)
for msg, ecode in pairs(M.flags) do
if code == ecode then
return msg
end
end
end
if code ~= M.flags.ok then
error(("sqlite.lua: couldn't connect to sql database, ERR: %s"):format(M.get_err_msg(code)))
end I've tried it on my machine and for some reason I got missue. maybe I got my firefox uri wrong. edit: nvm, a mode need to passed instead of nil |
@JanValiska can u checkout #132 and pass as second argument |
Chcecked out #132 and added second agrument to
|
That's odd. why the heck it's calling eval. are you still calling eval somewhere? |
oh wait the uri needs to be edited and have |
I've changed db connection to:
and it works. Also as you found I forgot to remove old eval functon from |
try local uri = "file:" .. utils.join_path(profile_dir, "places.sqlite") .. "?immutable=1"
local db = sqlite.new(uri, { open_mode = "ro" }):open() |
Nice, as soon as I merge open_v2 pr, another pr could be open in telescope-bookmarks to somehow have the above changes. For now, just have fun with telescope-bookmarks |
Awesome! Thank you! :) |
This should be closed by #132 merge automatically, np you are welcome. |
Hi,
this is more question than bug report.
I need to read firefox's bookmark database. But when FF is started the database is locked.
When I open database with immutable flag, I can read items from database:
Is it possible to open database using
sqlite.lua
library in immutable manner?Thank you.
The text was updated successfully, but these errors were encountered: