forked from marilena-staetu/mysql_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql.py
More file actions
35 lines (24 loc) · 879 Bytes
/
Copy pathmysql.py
File metadata and controls
35 lines (24 loc) · 879 Bytes
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
import os
import sys
from operation import Select
selected_database = None
while True:
query = input()
query_parts = query.split()
action = query_parts[0]
if action == 'select':
if selected_database is None:
print('ERROR 1046 (3D000): No database selected')
what = query_parts[1]
# print("Debug: what to select %s"% what_to_select)
from_keyword = query_parts[2]
requested_table = query_parts[3]
select_object = Select(what, selected_database, requested_table)
if action == 'use':
database_to_select = query_parts[1]
if not os.path.isdir("databases/%s" % database_to_select):
print("ERROR 1049 (42000): Unknown database '%s'" % database_to_select)
selected_database = database_to_select
if action == 'exit':
print('bye')
sys.exit(0)