-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgiturlfix.py
More file actions
executable file
·37 lines (34 loc) · 1.08 KB
/
giturlfix.py
File metadata and controls
executable file
·37 lines (34 loc) · 1.08 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
'''
update url from
https://code.engineering.redhat.com/gerrit/p/<project>.git
to
https://code.engineering.redhat.com/gerrit/<project>.git
'''
import MySQLdb
MySQL_SETTINGS = {
'host': 'localhost',
'user': 'root',
'db': 'gitview',
'passwd': ''
}
if __name__ == "__main__":
try:
conn = MySQLdb.connect(
host = MySQL_SETTINGS['host'],
user = MySQL_SETTINGS['user'],
passwd = MySQL_SETTINGS['passwd'],
db = MySQL_SETTINGS['db']
)
cur= conn.cursor()
cur.execute('select id, url from viewapp_project')
projects = list(cur.fetchall())
for project in projects:
url_new = project[1].replace('/p/', '/')
if url_new != project[1]:
sql = 'update viewapp_project set url = "%s" where id = %d' % (url_new, int(project[0]))
print sql
cur.execute(sql)
conn.commit()
print "URL UPDATE FINISH!"
except MySQLdb.Error, e:
print 'MySQL Error %d: %s' %(e.args[0], e.args[1])