1 |
569211e8
|
Julien Enselme
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
import pymysql as mysql
|
8 |
|
|
import re
|
9 |
|
|
|
10 |
|
|
db = mysql.connect(host="localhost", user="root", passwd="tata", db="expat", charset='utf8')
|
11 |
|
|
|
12 |
|
|
with db:
|
13 |
|
|
cur = db.cursor()
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
sql_select = """
|
18 |
|
|
SELECT uid, picture FROM users
|
19 |
|
|
"""
|
20 |
|
|
|
21 |
|
|
sql_update = """
|
22 |
|
|
UPDATE users SET picture = %s WHERE uid = %s
|
23 |
|
|
"""
|
24 |
|
|
|
25 |
|
|
cur.execute(sql_select)
|
26 |
|
|
rows = cur.fetchall()
|
27 |
|
|
for uid, picture in rows:
|
28 |
|
|
picture = re.sub(r'sites/assos.centrale-marseille.fr.expat/files/(.*)', r'\1', picture)
|
29 |
|
|
cur.execute(sql_update, (picture, uid))
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
sql_select = """
|
34 |
|
|
SELECT fid, filepath FROM files
|
35 |
|
|
"""
|
36 |
|
|
|
37 |
|
|
sql_update = """
|
38 |
|
|
UPDATE files SET filepath = %s WHERE fid = %s
|
39 |
|
|
"""
|
40 |
|
|
|
41 |
|
|
cur.execute(sql_select)
|
42 |
|
|
rows = cur.fetchall()
|
43 |
|
|
for fid, file_path in rows:
|
44 |
|
|
file_path = re.sub(r'sites/assos.centrale-marseille.fr.expat/files/(.*)', r'\1', file_path)
|
45 |
|
|
cur.execute(sql_update, (file_path, fid))
|
46 |
|
|
|
47 |
|
|
db.commit() |