add an optional config file to store commonly used tables in sql mode

in sql mode, only read tables if they are used in the query

refactor read_files a little to separate reading input and reading output