Test Failed
Push — master ( 8a6195...3318f0 )
by P.R.
10:24
created

pystratum_mysql.MySqlConnector   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 35
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A MySqlConnector.connect() 0 6 1
A MySqlConnector.disconnect() 0 6 1
A MySqlConnector.is_alive() 0 8 1
1 1
import abc
2
3 1
from mysql.connector import MySQLConnection
4
5
6 1
class MySqlConnector:
7
    """
8
    Interface for classes for connecting to a MySql instances.
9
    """
10
    # ------------------------------------------------------------------------------------------------------------------
11 1
    @abc.abstractmethod
12 1
    def connect(self) -> MySQLConnection:
13
        """
14
        Connects to the MySql instance.
15
        """
16
        raise NotImplementedError()
17
18
    # ------------------------------------------------------------------------------------------------------------------
19 1
    @abc.abstractmethod
20 1
    def disconnect(self) -> None:
21
        """
22
        Disconnects from the MySql instance.
23
        """
24
        raise NotImplementedError()
25
26
    # ------------------------------------------------------------------------------------------------------------------
27 1
    @abc.abstractmethod
28 1
    def is_alive(self) -> bool:
29
        """
30
        Returns whether Python is (still) connected to a MySQL or MariaDB instance.
31
32
        :rtype: bool
33
        """
34
        raise NotImplementedError()
35
36
# ----------------------------------------------------------------------------------------------------------------------
37