Advertisement
Guest User

Untitled

a guest
Dec 1st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. import pymysql.cursors
  2.  
  3. connection = pymysql.connect(host='xxxx',
  4. user='xxxx',
  5. password='xxxxx',
  6. db='xxxxx',
  7. port=3306)
  8.  
  9. try:
  10. with connection.cursor() as cursor:
  11. sql = "INSERT INTO couriers (type, api_key, username, enabled, salt, roles, password," \
  12. " created_at, phone_number, telegram_name) VALUES (%s, %s, %s, %s, %s, %s, %s, now(), %s, %s)"
  13.  
  14. cursor.execute(sql, ('pedestrian', '9hpbygz9f8cgccs0c88w4w8wkgossgs', 'T1', 1,
  15. '9dq0sn6fuf40gcgkcsc8sg4ggg4kgco', '[]',
  16. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  17. '+79603075765', 'RayneBloodlines'))
  18. connection.commit()
  19.  
  20. cursor.execute(sql, ('pedestrian','9hpbygz9f8cgccs0c88w4w8wkgossg2', 'T2', 1,
  21. '9dq0sn6fuf40gcgkcsc8sg4ggg4kgco', '[]',
  22. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  23. '+79603075763', 't2'))
  24. connection.commit()
  25.  
  26. cursor.execute(sql, ('bicycle','9hpbygz9f8cgccs0c88w4w8wkgossg3', 'T3', 1,
  27. '9dq0sn6fuf40gcgkcsc8sg4ggg41234', '[]',
  28. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  29. '+79603075761', 't3'))
  30. connection.commit()
  31.  
  32. cursor.execute(sql, ('bicycle','9hpbygz9f8cgccs0c88w4w8wkgossg4', 'T4', 1,
  33. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg22', '[]',
  34. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  35. '+79603075762', 't4'))
  36. connection.commit()
  37.  
  38. cursor.execute(sql, ('motorcycle','9hpbygz9f8cgccs0c88w4w8wkgossg5', 'T5', 1,
  39. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg33', '[]',
  40. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  41. '+79603075764', 't5'))
  42. connection.commit()
  43.  
  44. cursor.execute(sql, ('motorcycle','9hpbygz9f8cgccs0c88w4w8wkgossg6', 'T6', 1,
  45. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg44', '[]',
  46. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  47. '+79603075766', 't6'))
  48. connection.commit()
  49.  
  50. cursor.execute(sql, ('vehicle','9hpbygz9f8cgccs0c88w4w8wkgossg7', 'T7', 1,
  51. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg55', '[]',
  52. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  53. '+79603075767', 't7'))
  54. connection.commit()
  55.  
  56. cursor.execute(sql, ('vehicle','9hpbygz9f8cgccs0c88w4w8wkgossg8', 'T8', 1,
  57. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg66', '[]',
  58. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  59. '+79603075768', 't8'))
  60. connection.commit()
  61.  
  62. with connection.cursor() as cursor:
  63. sql = "UPDATE couriers SET location_date = '2018-12-30 16:59:52'" \
  64. "where username in ('T1','T2','T3','T4','T5','T6','T7','T8')"
  65. cursor.execute(sql)
  66. connection.commit()
  67.  
  68. with connection.cursor() as cursor:
  69. sql = "UPDATE couriers SET location_latitude = %s, location_longitude = %s where username = %s;"
  70. cursor.execute(sql, '55.775365', '37.468980', 'T1')
  71. connection.commit()
  72. cursor.execute(sql, '55.706658', '37.658636', 'T2')
  73. connection.commit()
  74. cursor.execute(sql, '55.759195', '37.643371', 'T3')
  75. connection.commit()
  76. cursor.execute(sql, '55.759177', '37.609677', 'T4')
  77. connection.commit()
  78. cursor.execute(sql, '55.730480', '37.592104', 'T5')
  79. connection.commit()
  80. cursor.execute(sql, '55.727793', '37.474156', 'T6')
  81. connection.commit()
  82. cursor.execute(sql, '55.758664', '37.618171', 'T7')
  83. connection.commit()
  84. cursor.execute(sql, '55.701256', '37.497081', 'T8')
  85. connection.commit()
  86.  
  87. finally:
  88. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement