Refactor API using Knex

@nicola Take a look at this and let me know if you're cool with this. I'll go ahead and update the docs and CLI to take advantage of the new API features. As mentioned, this should be fully backwards compatible. 

Closes #2