Move database opening to config module

Greater consistency with the way inverter and pvoutput connections are
done.