Created
October 4, 2012 18:43
-
-
Save vadimii/3835565 to your computer and use it in GitHub Desktop.
Generate SQL INSERT script with random key string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import random | |
def id_generator(size=8, chars=string.ascii_lowercase+string.digits): | |
return ''.join(random.choice(chars) for x in range(size)) | |
with open('data.tsv') as f: | |
data = f.readlines() | |
rows = [l.split('\t') for l in data] | |
for r in rows: | |
last, first, email, _, _ = r | |
print "insert into PotentialUser (\ | |
FisrtName, LastName, EMail, RegisterKey) values \ | |
(N'%s', N'%s', N'%s', N'%s')" % (first, last, email, id_generator()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment