You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
735 B
Python
27 lines
735 B
Python
import oursql, csv, random, string
|
|
|
|
# input.csv must be in the format vpsid,email
|
|
|
|
db = oursql.connect(host="localhost", user="root", passwd="", db="transfer")
|
|
reader = csv.reader(open("emails.csv", "r"))
|
|
|
|
emails = []
|
|
c = db.cursor()
|
|
|
|
for entry in reader:
|
|
vps_id, email = entry
|
|
c.execute("UPDATE entries SET `EmailAddress` = ? WHERE `VpsId` = ?", (email, vps_id))
|
|
print "Added e-mail address for VPS %s" % (vps_id)
|
|
|
|
if email not in emails:
|
|
emails.append(email)
|
|
|
|
db.commit()
|
|
|
|
for email in emails:
|
|
if email.strip() != "":
|
|
random_key = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in xrange(0, 16))
|
|
c.execute("INSERT INTO emails (`EmailAddress`, `Key`) VALUES (?, ?)", (email, random_key))
|
|
|
|
db.commit()
|