-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
110 lines (72 loc) · 1.92 KB
/
main.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
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
import sqlite3 as lite
import sys
con = None
def getSQLiteVersion():
try:
con = lite.connect('installbase.db')
cur = con.cursor()
cur.execute('SELECT SQLITE_VERSION()')
data = cur.fetchone()
return "SQLite version: " + str(data)
except lite.Error, e:
print "Error %s:" % e.args[0]
sys.exit(1)
finally:
if con:
con.close()
def getInstallBaseCust():
try:
result = "Here are all of your customers:\n"
con = lite.connect('installbase.db')
cur = con.cursor()
cur.execute('select distinct CS_CUSTOMER_NAME from tbl_installbase')
rows = cur.fetchall()
for row in rows:
result += str(row[0]) + "\n"
return result
except lite.Error, e:
print "Error %s:" % e.args[0]
sys.exit(1)
finally:
if con:
con.close()
def getInstallBaseVNX():
try:
con = lite.connect('installbase.db')
cur = con.cursor()
cur.execute('select CS_CUSTOMER_NAME, PRODUCT_GROUP, ITEM_SERIAL_NUMBER from tbl_installbase where PRODUCT_GROUP like \'VNX%\'')
rows = cur.fetchall()
result = "Here are all of your VNX systems:\n"
for row in rows:
result += row[0] + "\n"
result += row[1] + "\n"
result += row[2] + "\n"
return result
except lite.Error, e:
print "Error %s:" % e.args[0]
sys.exit(1)
finally:
if con:
con.close()
def getInstallBaseISILON():
try:
con = lite.connect('installbase.db')
cur = con.cursor()
cur.execute('select CS_CUSTOMER_NAME, PRODUCT_GROUP, ITEM_SERIAL_NUMBER from tbl_installbase where PRODUCT_GROUP like \'Isilon%\'')
rows = cur.fetchall()
result = "Here are all of your Isilon systems:\n"
for row in rows:
result += row[0] + "\n"
result += row[1] + "\n"
result += row[2] + "\n"
return result
except lite.Error, e:
print "Error %s:" % e.args[0]
sys.exit(1)
finally:
if con:
con.close()
print getSQLiteVersion()
print getInstallBaseCust()
print getInstallBaseVNX()
print getInstallBaseISILON()