-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprdb.py
56 lines (49 loc) · 1.63 KB
/
sprdb.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
51
52
53
54
55
56
#!/usr/bin/python3.10.6
# -*- coding: utf-8 -*-
#
# @Time : 2024/4/23 下午2:01
# @Author : ASXE
import sys
from common.log import Logger, curdir
from parser import parser
from server.serve import startupServe, destartupServe
logger = Logger(logDir=f'{curdir}/logs/local')
def local():
while True:
print("sprDB >>> ", end='')
statement = input('')
if statement == 'exit':
print('Good Bye!')
break
elif statement == 'startup-auto':
startupServe()
continue
elif statement == 'destartup-auto':
destartupServe()
continue
elif statement == 'help':
helps = [
"use < database >",
"create database < database >",
"create table < table > (< column > type, ...)",
"select * | < column > from < table > [where ...]",
"insert into < table > [(column, ...)] values (...) [,(...)]",
"update < table > set < column=..., ... > [where ...]",
"delete from < table > [where ...]"
]
for help in helps:
print(help)
continue
syntax = parser.SyntaxParser(statement, logger).parse()
try:
parser.SemanticParser(logger).main(syntax)
except:
pass
if __name__ == '__main__':
print('Copyright (c) 2024 SprDB Software Foundation. All Rights Reserved.')
print('Type "help", "exit", "startup-auto" for more information.')
try:
local()
except KeyboardInterrupt:
print("Terminating threads...")
sys.exit(0)