Corrected a condition error where trying to make a request with a closed connection still generates exceptions.
It is better to open the connection if it wasn't opened before.
Removed awful code duplications, since currently the only thing different between MySQL and SQLite is the way to open connection.
Merge pull request #8 from Elarcis/master

Corrected major condition error and removed duplicated code.