Extracting SQL related stuff to separate module