For a long-running scanner function, isolated the sqlite db connection to once, before the scan function is defined (otherwise, db will lock every time the scan function is invoked)