get_create_one_user_sql.sql.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python
  2. # coding=utf8
  3. """
  4. @author: liaoqiqi
  5. 93b9e2669a8965572610063d07559e6d
  6. a195225bc1867d6a15aff7859ca076198d1d97b2
  7. /* msoa msoaSH*/
  8. INSERT INTO `user` (`user_id`, `name`, `password`, `token`, `ownapps`,`role_id`) VALUES (null, 'msoa', 'a195225bc1867d6a15aff7859ca076198d1d97b2', '3da70a83f9d386362fd5dfa369ddda3f95a86508','', '2');
  9. """
  10. import hashlib
  11. import uuid
  12. if __name__ == '__main__':
  13. user_name = raw_input('name:')
  14. password = raw_input('password:')
  15. ownApps = raw_input('ownapps(空表示所有app):')
  16. role_id = raw_input('role(正常角色(1);管理员(2);只读管理员(3)):')
  17. sha1 = hashlib.sha1()
  18. sha1.update(password)
  19. new_password = sha1.hexdigest()
  20. dat = str(uuid.uuid4())
  21. sha1.update(dat + user_name)
  22. token = sha1.hexdigest()
  23. print "INSERT INTO `user` (`user_id`, `name`, `password`, `token`,`ownapps`,`role_id`) VALUES " \
  24. + "(null,'" + user_name + "' , '" + new_password + "' , '" + token + "' , '" + ownApps + "' ," + role_id + ")"