For CSV, you could write a DCG grammar for the particular file format at hand.
Integration with a relational DB, itself being based on logic, would be very different. Most Prologs have APIs to map tables to predicates.