WIP: initial implementation of connection and query protocol, and API.

@tyro89 any feedback?