server/scripts/register/update.py

30 lines
693 B
Python
Raw Normal View History

2001-12-30 12:49:36 +01:00
#!/usr/bin/env python
import MySQLdb
import re
import sys
dbname=sys.argv[1]
file=sys.argv[2]
game=int(sys.argv[3])
2002-01-02 14:29:22 +01:00
infile=open(file, 'r')
2001-12-30 12:49:36 +01:00
db=MySQLdb.connect(db=dbname)
cursor=db.cursor()
matchrenum=re.compile(
r"""\brenum\s([^\s]+)\s(.*)\n""",
2001-12-30 12:49:36 +01:00
re.IGNORECASE | re.DOTALL | re.VERBOSE)
matchdropout=re.compile(
r"""dropout\s(.*)""",
re.IGNORECASE | re.DOTALL | re.VERBOSE)
for line in infile.readlines():
match=matchrenum.match(line)
if match!=None:
fold=match.group(1)
fnew=match.group(2)
2002-01-02 14:29:22 +01:00
i=cursor.execute("update subscriptions set faction='"+fnew+"' where game="+str(game)+" and faction='"+fold+"'")
2001-12-30 12:49:36 +01:00
if i!=1:
print "could not renum faction "+fold+" to new id "+fnew