G.Hemanth Sai commited on
Commit
1e1ce36
1 Parent(s): addbc00

Established connection with DB and basic files

Browse files
.gitignore CHANGED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PyCharm files
2
+ .idea
3
+
4
+ # VScode files
5
+ .vscode
6
+
7
+ # env files
8
+ .env
9
+
10
+ # cache files
11
+ __pycache__
12
+ .vercel
13
+ tempCodeRunnerFile.py
14
+
15
+ # models
16
+ docguptea/static/models/codellama*
AUTHORS ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Mayuresh Agashe <https://github.com/mayureshagashe2105>
2
+ Hemanth Sai <https://github.com/HemanthSai7>
CODEOWNERS ADDED
File without changes
app.py ADDED
File without changes
backend/core/Exceptions.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ from backend.models import GeneralResponse, TokenSchema
4
+
5
+
6
+ class InvalidCredentialsException(Exception):
7
+ def __init__(self, token_result: GeneralResponse):
8
+ self.token_result = token_result
9
+ self.set_statuses()
10
+ super(InvalidCredentialsException, self).__init__()
11
+
12
+ def set_statuses(self):
13
+ self.token_result.status = 'login_failed'
14
+
15
+ def __repr__(self):
16
+ return json.dumps(self.token_result)
17
+
18
+ class ExistingUserException(Exception):
19
+ def __init__(self, response_result: GeneralResponse):
20
+ self.response_result = response_result
21
+ self.set_statuses()
22
+ super(ExistingUserException, self).__init__()
23
+
24
+ def set_statuses(self):
25
+ self.response_result.status = f'failed'
26
+ self.response_result.message.append(f'user with this AADHAR Number already has an account')
27
+ self.response_result.message[0] = 'authenticated'
28
+
29
+ def __repr__(self):
30
+ return json.dumps(self.response_result)
31
+
32
+ class InfoNotFoundException(Exception):
33
+ def __init__(self, response_result: GeneralResponse, message: str):
34
+ self.response_result = response_result
35
+ self.message = message
36
+ self.set_statuses()
37
+ super(InfoNotFoundException, self).__init__(message)
38
+
39
+ def set_statuses(self):
40
+ self.response_result['status'] = 'abort'
41
+ self.response_result['message'][0] = 'authenticated'
42
+ self.response_result['message'].append(self.message)
43
+
44
+ def __repr__(self):
45
+ return json.dumps(self.response_result)
backend/utils/DBConnection.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Import Important Packages"""
2
+ import mysql.connector
3
+
4
+ from backend.core.ConfigEnv import config
5
+
6
+
7
+ class DBConnection:
8
+ """DBConnection Class. It ensures only one instance of the class is
9
+ created and it is accessible from everywhere. It is used in the
10
+ design of logging classes, Configuration classes where we need to have
11
+ only one instance of the class. There is no need to create multiple
12
+ instances of each operation across all components of application.
13
+
14
+ Raises:
15
+ Exception: It raises an exception if the client instance is not created.
16
+ """
17
+ __client = None #This is the client variable that is used to connect to the database
18
+ _flag = False
19
+ def __init__(self):
20
+ """This is the constructor of the class. It is used to create the client
21
+ variable. It also checks if the client instance is already created.
22
+ If the client instance is already created, then it does not create a
23
+ new client instance.
24
+ """
25
+ if DBConnection.__client is not None:
26
+ raise Exception("This class is a singleton!")
27
+ else:
28
+ creds={
29
+ 'host':config.HOSTNAME,
30
+ 'user':config.UID,
31
+ 'password':config.PASSWORD,
32
+ 'database':config.DATABASE
33
+ }
34
+ DBConnection.__client = mysql.connector.connect(**creds)
35
+ DBConnection._flag = True
36
+
37
+ @staticmethod # A static method is a method that is called without creating an instance of the class.
38
+ def get_client():
39
+ """The get_client() function is used to get the client instance.
40
+
41
+ Returns:
42
+ DBConnection.__client: It returns the client instance.
43
+ """
44
+ return DBConnection.__client
45
+
46
+ @classmethod
47
+ def is_connected(cls)->bool:
48
+ """property to get the database connection flag.
49
+ Returns:
50
+ DBConnection._flag: bool. Connection status to the DB.
51
+ """
52
+ return cls._flag
53
+
54
+
55
+
56
+
57
+
backend/utils/__init__.py ADDED
File without changes
backend/utils/prompt.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are an AI Coding Assitant and your task is to generate an elaborate, high quality docstring for the query function given by the user. Below is the user's query .
2
+ Query: {query}
3
+
4
+ You just return the helpful docstring.
5
+ Helpful Answer:
6
+ def add(a,b):
7
+ return a+b
8
+
9
+ The generated docstring should be:
10
+ This function adds two numbers
11
+
12
+ Args:
13
+ a: int. First number to add
14
+ b: int. Second number to add
15
+
16
+ Returns:
17
+ Sum of a and b
backend/utils/scopes.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from typing import Callable
2
+
3
+ from backend.models import User