I'm making another plugin that's going to use a sqlite database. 2 questions.
A) Now that sqlite's built in, the plugin doesn't need to be trusted, right?
B) I was thinking of checking a variable for the directory path to the db, and if the var is not there to pop open utils.directorypicker. Is there a way to test if a file exists? I thought about io.open, but then it'd definitely need to be trusted, right? Is there a way I can tell if the user moved/deleted the db, and re-pop open the directory picker?
Hmm... I suppose I could do something like
Is there an easier way?
A) Now that sqlite's built in, the plugin doesn't need to be trusted, right?
B) I was thinking of checking a variable for the directory path to the db, and if the var is not there to pop open utils.directorypicker. Is there a way to test if a file exists? I thought about io.open, but then it'd definitely need to be trusted, right? Is there a way I can tell if the user moved/deleted the db, and re-pop open the directory picker?
Hmm... I suppose I could do something like
if not var.dbpath then
var.dbpath = utils.directorypicker("Select where to store the database.")
if var.dbpath then
InitDB = true
else
EnablePlugin(GetPluginID(), false)
print("Disabling for now. Plugin needs a db.")
end
end
stmt = db:prepare("SELECT * from SQLITE_MASTER where name = 'Mytable'")
if stmt:step() ~= 100 and InitDB == false then
--reselect
end
stmt:finalize()
--.....blah blah
Is there an easier way?