Added generic dosql function with optional echo reporting
Rewrote setup code to use new dosql function