-
Notifications
You must be signed in to change notification settings - Fork 1
/
DataBaseHandler.py
50 lines (40 loc) · 1.46 KB
/
DataBaseHandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
""" This file creates the interface for databases"""
from abc import abstractmethod, ABC
from __future__ import annotations
from typing import Any
"""
DatabaseMain class
Methods:
- login() - responsible for login to database
- connection() - responsible for connection with database
- cursor() - responsible for creating cursor to database
- create_database() - responsible for creating database
- create_table() - responsible for creating table
- insert_into_table() - responsible for insert data into table
"""
class DatabaseMain(ABC):
""" Database interface class"""
@abstractmethod
def login(self, **kwargs) -> DatabaseMain:
""" Method to login with database"""
pass
@abstractmethod
def connection(self) -> Any:
""" Method to connect with database"""
pass
@abstractmethod
def cursor(self) -> Any:
""" Method to create a cursor"""
pass
@abstractmethod
def create_database(self, database_name: str) -> DatabaseMain:
""" Method to create database"""
pass
@abstractmethod
def create_table(self, table_name: str, **kwargs) -> DatabaseMain:
""" Method to create table"""
pass
@abstractmethod
def insert_into_table(self, table_name: str, *args) -> DatabaseMain:
""" Method to insert data into table"""
pass