make an attempt at a SQL API, hope not to regret this :)