Sql support, fixes #9
Implement suggestions from @ukd1 and @smathieu
Merge pull request #20 from gkop/sql-support-9

Sql support, fixes #9