Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import pymysql.cursors
  2. import json
  3.  
  4. connect_host = 'localhost'
  5. connect_user = 'root'
  6. connect_pass = ''
  7. connect_db = 'bot-one'
  8. connect_charset = 'utf8mb4'
  9.  
  10. connect_vk_login = '12'
  11. connect_vk_pass = '123'
  12. connect_vk_id = '09934'
  13. connect_vk_app = '77362'
  14.  
  15. connection = pymysql.connect(host=connect_host,
  16. user=connect_user,
  17. password=connect_pass,
  18. db=connect_db,
  19. charset=connect_charset,
  20. cursorclass=pymysql.cursors.DictCursor)
  21. print("База данных подключена успешно.")
  22.  
  23. cursor = connection.cursor()
  24. sql = """CREATE TABLE ACCAUNT (
  25. LOGIN INT NOT NULL,
  26. PASS INT,
  27. ID INT,
  28. ID_APP INT )"""
  29. cursor.execute(sql)
  30.  
  31. #======= Переделать то что внизу ==========
  32.  
  33. sql = "INSERT INTO ACCAUNT(LOGIN, \
  34. PASS, ID, ID_APP) \
  35. VALUES ('str', 'str', 'str, 'str' )" % \
  36. (connect_vk_login, connect_vk_pass, connect_vk_id, connect_vk_app)
  37. try:
  38. cursor.execute(sql)
  39. connection.commit()
  40. except:
  41. connection.rollback()
  42. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement