Skip to content

Instantly share code, notes, and snippets.

@jdiez17
Created December 9, 2014 11:48
Show Gist options
  • Save jdiez17/a6e455581f3fffdeacd8 to your computer and use it in GitHub Desktop.
Save jdiez17/a6e455581f3fffdeacd8 to your computer and use it in GitHub Desktop.
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