Preliminary OH sql code. WARNING: UNTESTED

Will probably break, just wanted to push to prevent duplication