Created
December 9, 2014 11:48
-
-
Save jdiez17/a6e455581f3fffdeacd8 to your computer and use it in GitHub Desktop.
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 random | |
query = 'insert into employees (emp_id, first_name, surname, salary, dept_id, comm_pct) VALUES ("%s", "%s", "%s", %d, "%s", %s);' | |
def get_id(name, surname): | |
return "%s%s%02d" % (name[0], surname[0], random.randint(0, 99)) | |
if __name__ == '__main__': | |
names = [line.rstrip() for line in open("first-names.txt")] | |
surnames = [line.rstrip() for line in open("names.txt")] | |
departments = ["COM1", "Sal1", "Its1", "Mkt1"] | |
for i in range(50): | |
name = random.choice(names) | |
surname = random.choice(surnames) | |
emp_id = get_id(name, surname) | |
dept_id = random.choice(departments) | |
salary = random.randint(20000, 60000) | |
comm_pct = random.randint(0, 10) / 100 | |
if comm_pct == 0: | |
comm_pct = "null" | |
print(query % (emp_id, name, surname, salary, dept_id, comm_pct)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment