"""A base class for databases to inherit from."""


class Database():
    """A base database.

    Database classes are used to persist key/value pairs in a database.

    """

    def __init__(self, config):
        """Create the database.

        Set some basic properties from the database config such as the name
        of this database. It could also be a good place to setup properties
        to hold things like the database connection object and the database
        name.

        Args:
            config (dict): The config for this database specified in the
                           `configuration.yaml` file.

        """
        self.name = ""
        self.config = config
        self.client = None
        self.database = None

    async def connect(self, opsdroid):
        """Connect to database service and store the connection object.

        This method should connect to the given database using a native
        python library for that database. The library will most likely involve
        a connection object which will be used by the put and get methods.
        This object should be stored in self.

        Args:
            opsdroid (OpsDroid): An instance of the opsdroid core.

        """
        raise NotImplementedError

    async def disconnect(self):
        """Disconnect from the database.

        This method should disconnect from the given database using a native
        python library for that database.

        """
        pass

    async def put(self, key, data):
        """Store the data object in a database against the key.

        The data object will need to be serialised in a sensible way which
        suits the database being used and allows for reconstruction of the
        object.

        Args:
            key (string): The key to store the data object under.
            data (object): The data object to store.

        Returns:
            bool: True for data successfully stored, False otherwise.

        """
        raise NotImplementedError

    async def get(self, key):
        """Return a data object for a given key.

        Args:
            key (string): The key to lookup in the database.

        Returns:
            object or None: The data object stored for that key, or None if no
                            object found for that key.

        """
        raise NotImplementedError

opsdroid/database/__init__.py
"""A base class for databases to inherit from."""


class Database():
    """A base database.

    Database classes are used to persist key/value pairs in a database.

    """

    def __init__(self, config):
        """Create the database.

        Set some basic properties from the database config such as the name
        of this database. It could also be a good place to setup properties
        to hold things like the database connection object and the database
        name.

        Args:
            config (dict): The config for this database specified in the
                           `configuration.yaml` file.

        """
        self.name = ""
        self.config = config
        self.client = None
        self.database = None

    async def connect(self, opsdroid):
        """Connect to database service and store the connection object.

        This method should connect to the given database using a native
        python library for that database. The library will most likely involve
        a connection object which will be used by the put and get methods.
        This object should be stored in self.

        Args:
            opsdroid (OpsDroid): An instance of the opsdroid core.

        """
        raise NotImplementedError

    async def disconnect(self, opsdroid):
        """Disconnect from the database.

        This method should disconnect from the given database using a native
        python library for that database.

        """
        pass

    async def put(self, key, data):
        """Store the data object in a database against the key.

        The data object will need to be serialised in a sensible way which
        suits the database being used and allows for reconstruction of the
        object.

        Args:
            key (string): The key to store the data object under.
            data (object): The data object to store.

        Returns:
            bool: True for data successfully stored, False otherwise.

        """
        raise NotImplementedError

    async def get(self, key):
        """Return a data object for a given key.

        Args:
            key (string): The key to lookup in the database.

        Returns:
            object or None: The data object stored for that key, or None if no
                            object found for that key.

        """
        raise NotImplementedError

opsdroid/database/__init__.py
diff --git a/opsdroid/database/__init__.py b/opsdroid/database/__init__.py
index e05b46ad6..e4ea82bb4 100644
--- a/opsdroid/database/__init__.py
+++ b/opsdroid/database/__init__.py
@@ -40,7 +40,7 @@ async def connect(self, opsdroid):
         """
         raise NotImplementedError
 
-    async def disconnect(self):
+    async def disconnect(self, opsdroid):
         """Disconnect from the database.
 
         This method should disconnect from the given database using a native
diff --git a/tests/test_database.py b/tests/test_database.py
index bf940ab98..b6c855eae 100644
--- a/tests/test_database.py
+++ b/tests/test_database.py
@@ -26,7 +26,7 @@ async def test_connect(self):
     async def test_disconnect(self):
         database = Database({})
         try:
-            await database.disconnect()
+            await database.disconnect(None)
         except NotImplementedError:
             self.fail("disconnect() raised NotImplementedError unexpectedly!")
 

Cannot disconnect from SQLite
<!-- Before you post an issue or if you are unsure about something join our gitter channel https://gitter.im/opsdroid/ and ask away! We are more than happy to help you. -->
# Description
SQLite database connector can’t disconnect because of wrong method signature.

## Steps to Reproduce
Enable the SQLite database module, then try to shut down the bot.


## Expected Functionality
The bot should shut down.

## Experienced Functionality
This error message on the console, and the bot remains running (but with the connectors already disconnected).

```
ERROR opsdroid.core: {'message': 'Task exception was never retrieved', 'exception': TypeError('disconnect() takes 1 positional argument but 2 were given',), 'future': <Task finished coro=<OpsDroid.handle_signal() done, defined at /home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py:121> exception=TypeError('disconnect() takes 1 positional argument but 2 were given',)>}
```

## Versions
- **Opsdroid version:** 0.13.0
- **Python version:** 3.6.6 (bundled with Fedora 28)
- **OS/Docker version:** Fedora 28, no Docker involved

## Additional information
It seems the method signature of `Database.disconnect()` is wrong (should be `async def disconnect(self, opsdroid)`) or the caller (`OpsDroid.unload()`) should not pass the `opsdroid` instance to `database.disconnect()` (personally i’d vote for the former).
