-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (29 loc) · 1.07 KB
/
main.py
File metadata and controls
39 lines (29 loc) · 1.07 KB
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
# main.py
from Client import Client
if __name__ == "__main__":
client = Client()
address = input(">>> Connect to KawulaSQL: ")
host, port = address.split(':')
try:
client.connect(host, int(port))
print("Connected to address " + address)
print("Welcome to KawulaSQL!")
print("Enter your SQL query or type 'exit' to quit.\n")
while True:
query = input("Please enter your SQL query: ").strip()
dummy = "SELECT * FROM department;"
if query.lower() == "exit":
print("Exiting KawulaSQL. Goodbye!")
break
try:
client.send(query.encode())
client.send(dummy.encode())
except Exception as e:
print(f"Error while sending to server: {str(e)}")
try:
response = client.receive()
print(response)
except Exception as e:
print(f"Server Response Error: {str(e)}")
except Exception as e:
print(f">>> Connection Error: {str(e)}")