-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstructure.py
More file actions
97 lines (78 loc) · 2.77 KB
/
structure.py
File metadata and controls
97 lines (78 loc) · 2.77 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
#! /usr/bin/env python
# This script is a part of SQL_easy
# written by DiaaDiab
from settings import *
import os
from dealway import *
import readline
class Structure(object):
def __init__(self, MyConnection, Cursor):
self.MyConnection = MyConnection
self.Cursor = Cursor
def Show_dbs(self):
global UserName
global PassWord
print '[*] All DataBases:'
statement = 'mysql -u%s -p%s --execute="SHOW DATABASES;"' % (UserName, PassWord)
try:
os.system(statement)
except:
print '[--] SyStem Error !!'
def Create_db(self, db_name):
MySQL_Query = 'create database %s' % db_name
try:
self.Cursor.execute(MySQL_Query)
print '[*] Your DataBase has been Created:'
except:
print '[--] You have SQL error !!'
def Show_tables(self, db_name):
statement = 'mysql -u%s -p%s --execute="use %s; show tables;"' % (UserName, PassWord, db_name)
try:
os.system(statement)
print '[*] DataBase Tables: '
except:
print '[--] SyStem Error !!'
def Create_table(self, t_name):
print '[!!] please never make id, it will make automatic by programme.'
number_Of_fields = int(raw_input('How man field you want to make in your table!!: '))
print '[+] Enter your fields following by press enter button after every field.'
MySQL_Query = '(Id INT PRIMARY KEY AUTO_INCREMENT'
cons = 0
for i in range(number_Of_fields):
fieled_name = raw_input('>>')
if cons == number_Of_fields - 1:
MySQL_Query += ', %s TEXT(200))' % fieled_name
else:
MySQL_Query += ', %s TEXT(200)' % fieled_name
cons += 1
Ct = 'create table %s' % t_name
MySQL_Query = Ct + ' ' + MySQL_Query
try:
self.Cursor.execute(MySQL_Query)
print '[*] Table has been Created.'
except:
print '[--] You have SQL error !!'
def Drop_db(self, db_name):
MySQL_Query = 'drop database %s' % db_name
try:
self.Cursor.execute(MySQL_Query)
print '[*] Your DataBase has been Droped.'
except:
print '[--] You have SQL error !!'
def Drop_table(self, t_name):
MySQL_Query = 'drop table %s' % t_name
try:
self.Cursor.execute(MySQL_Query)
print '[*] Your Table has been Created:'
except:
print '[--] You have SQL error !!'
def SQL_Shell(self):
command = 'mysql -u%s -p%s' % (UserName, PassWord)
try:
os.system(command)
except:
print '[--] SyStem Error !!'
def main():
pass
if __name__ == '__main__':
main()