Lazy openDB() 

To fix #1191 this PR makes the openDatabase check lazy so it will be able to find the sqlite plugin.