Skip to content

Commit 63ecb19

Browse files
committed
Added deleteDatabase
1 parent 1449b2c commit 63ecb19

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

PySql.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ def __init__(self, username, userPassword):
1212
print("Invalid Credentials")
1313
exit(-1)
1414

15-
1615
########## Database Stuffs ##########
1716
def useDatabase(self, databaseName):
18-
self.__safeExecution(f"USE {databaseName}", "Database Using")
17+
self.__safeExecution(f"USE {databaseName};", "Using Database")
1918

2019
def createDatabase(self, databaseName):
21-
self.__safeExecution(f"CREATE DATABASE{databaseName}", "Database Creation")
20+
self.__safeExecution(f"CREATE DATABASE{databaseName};", "Database Creation")
2221

23-
22+
def deleteDatabase(self, databaseName):
23+
self.__safeExecution(f"DROP DATABASE {databaseName};", "Database Deletion")
24+
25+
26+
########## Private Methods ##########
27+
2428
def __safeExecution(self, command, typeOfCommand="Unknown"):
2529
try:
2630
self.cursor.execute(command)
2731
except:
2832
print(f"Problem: {typeOfCommand}");
29-
exit(-1)
33+
exit(-1)
34+

0 commit comments

Comments
 (0)