Modify database interaction in datfile_scan

Just modified the database connection in datfile_scan. Still not
finished.