-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathupgrade.py
38 lines (31 loc) · 1017 Bytes
/
upgrade.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
from sqltools import *
import sys, json
try:
from getpass import getpass
except ImportError:
print "Missing Python module 'getpass'. You can continue but password will echo on console\n"
sys.argv.pop(0)
print "Please make sure you have backed up your database before proceeding"
username=raw_input('Enter DB admin username: ')
try:
password=getpass('Enter DB admin password: ')
except NameError:
password=raw_input('Enter DB admin password: ')
try:
if len(sys.argv) == 1:
try:
upgradeFile=sys.argv[0]
with open(upgradeFile) as fp:
for line in fp:
cmd=line.strip('\n')
dbUpgradeExecute(username,password,cmd)
dbCommit()
print "Patches Applied Successfully"
except Exception,e:
dbRollback()
print str(e)+" problem applying command: "+str(cmd)+" \nPossibly already applied?"
else:
print "Usage Guidelines: python upgrade.py <patchfile>"
except Exception,e:
dbRollback()
print "Something failed trying to upgrade "+str(e)