SQL backend

This will need a while to be ready, but I figure already putting up a PR for code review is a good idea.
Well, it's a massive syntactic abuse; it has the unfortunate consequence that the name of the function becomes bound to the deferred, since it does:

```
def f(*args):
   ....
f = d.addCallback(f)
```

I like the addCallback-before-function-definition look: it makes the function def more like a lambda except, well, a real function with statements and stuff. But I'll happily throw all of them out if people think it's unfortunate :)