-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSQL_easy.py
More file actions
executable file
·159 lines (138 loc) · 5.3 KB
/
SQL_easy.py
File metadata and controls
executable file
·159 lines (138 loc) · 5.3 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#! /usr/bin/env python
# This script is a part of SQL_easy
# written by DiaaDiab
from dealway import Dealing
from settings import *
from structure import Structure
#from hashes import Encrypt, Decrypt, Info
import readline
class SQL_easy(object):
def MySQL_Screen_1(self):
print
print '-----------------------------------------'
print '[01] Show DataBases On Server. '
print '[02] Create New DataBase. '
print '[03] Delete DataBase From Server. '
print '[04] Use One Of DataBase.'
print '[05] Take MySQL Shell. '
print '[06] Take Dump From DataBase. '
print '[00] Quit. '
print '-----------------------------------------'
print '***********Choose By Number***********'
def MySQL_Screen_2(self):
print '-----------------------------------------'
print '[01] Show Tables In DataBase. '
print '[02] Create New Table. '
print '[03] Show All Records In Table. '
print '[04] Add Record To Table. '
print '[05] Update Record In Table. '
print '[06] View Specific Record From Table. '
print '[07] Delete Table From DataBase. '
print '[08] Exit Current DataBase. '
print '[00] Quit. '
print '-----------------------------------------'
print '***********Choose By Number***********'
def repeat_1(self):
ch = raw_input('[**] (Q)uite, else Continue: ')
ch = ch.lower()
if ch == 'q':
sys.exit()
else:
self.MySQL_Screen_1()
def repeat_2(self):
ch = raw_input('[**] (Q)uite, else Continue: ')
ch = ch.lower()
if ch == 'q':
sys.exit()
else:
self.MySQL_Screen_2()
def main():
print '''
##### ##### #
# # # # # ###### ## #### # #
# # # # # # # # # #
##### # # # ##### # # #### #
# # # # # # ###### # #
# # # # # # # # # # #
##### #### # ####### ###### # # #### #
#######
'''
# initialize programme
MyConnection, Cursor = InitConnection()
# structure instance
struc = Structure(MyConnection, Cursor)
# dealway instance
deal = Dealing(MyConnection, Cursor)
if MyConnection != None and Cursor != None:
# display screen for user
showing = SQL_easy()
showing.MySQL_Screen_1()
while True:
ch = raw_input('[**] Choice:')
if ch == '1':
struc.Show_dbs()
showing.repeat_1()
if ch == '2':
databaseName = raw_input('[*] Enter Your New DataBase Name: ')
struc.Create_db(databaseName)
showing.repeat_1()
if ch == '3':
databaseName = raw_input('[*] Enter DataBase Name That You Want To Drop It Down: ')
struc.Drop_db(databaseName)
showing.repeat_1()
if ch == '4':
databaseName = raw_input('[*] Enter DataBase Name That You Want To Use It: ')
deal.Change_db(databaseName)
showing.MySQL_Screen_2()
while True:
ch = raw_input('[**] Choice: ')
if ch == '1':
struc.Show_tables(databaseName)
showing.repeat_2()
if ch == '2':
tableName = raw_input('[*] Enter Your New Table Name: ')
struc.Create_table(tableName)
showing.repeat_2()
if ch == '3':
tableName = raw_input('[*] Enter Table Name That You Want To Deal With It: ')
deal.View_all(tableName, databaseName)
showing.repeat_2()
if ch == '4':
tableName = raw_input('[*] Enter Table Name That You Want To Deal With It: ')
deal.Add(tableName)
showing.repeat_2()
if ch == '5':
tableName = raw_input('[*] Enter Table Name That You Want To Deal With It: ')
deal.Update(tableName)
showing.repeat_2()
if ch == '6':
tableName = raw_input('[*] Enter Table Name That You Want To Deal With It: ')
deal.View(tableName, databaseName)
showing.repeat_2()
if ch == '7':
tableName = raw_input('[*] Enter Table Name That You Want To Drop It: ')
struc.Drop_table(tableName)
showing.repeat_2()
if ch == '8':
showing.MySQL_Screen_1()
break
if ch == '0':
print '[**] bye'
sys.exit()
if ch == '5':
struc.SQL_Shell()
showing.MySQL_Screen_1()
if ch == '6':
databaseName = raw_input('[*] Enter DataBase Name That You Want To Take Dump From It: ')
deal.Dump(databaseName)
showing.repeat_1()
if ch == '0':
print '[**] bye'
sys.exit()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print
print '[-] Bye'
sys.exit()