dbwrap: determine basename once instead of three times