Connect to db

Use a factory to get the correct database connection to support multiple backends.