Advertisement
MertcanGokgoz

Mysql Random Row with faker lib

Dec 20th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. # /usr/bin/python2.7
  2. __author__ = 'Mertcan Gokgoz'
  3.  
  4. import random
  5. import decimal
  6. from faker import Factory
  7.  
  8. fake = Factory.create('tr_TR')
  9.  
  10. uret_random = raw_input("Kac Adet Kayit Gerekiyor: ")
  11.  
  12.  
  13. def mysql_random_employees():
  14.     for _ in range(0, int(uret_random)):
  15.         name = "'" + fake.first_name() + "'"
  16.         surname = "'" + fake.last_name() + "'"
  17.         email = "'" + fake.email() + "'"
  18.         phone = str(fake.phone_number())
  19.         hire_date = "'" + str(fake.date_time()) + "'"
  20.         job_id = str(random.randint(0, 9))
  21.         salary = str(decimal.Decimal(random.randrange(1000)) / 8)
  22.         comission = str(decimal.Decimal(random.randrange(100)) / 4)
  23.         manager_id = str(random.randint(0, 9))
  24.         department_id = str(random.randint(0, 9))
  25.         print "INSERT INTO EMPLOYEES VALUES(NULL," + name + "," + surname + "," + email + "," + phone + "," + hire_date + "," + job_id + "," + salary + "," + comission + "," + manager_id + "," + department_id + ");"
  26.  
  27.  
  28. mysql_random_employees()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement