Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. import pymysql.cursors
  2.  
  3. connection = pymysql.connect(host='localhost',
  4.                             user='max',
  5.                             password='27ChaNel',
  6.                             db='kingdom_elementsDB',
  7.                             charset='utf8mb4',
  8.                             cursorclass=pymysql.cursors.DictCursor)
  9.  
  10.  
  11. def new_user():
  12.     with connection.cursor() as cursor:
  13.         sql = "INSERT INTO `main` (`name`, `sex`, `age`, `money`, `fields`, `enemyes`, `warriors`) VALUES (%s, %s, %s, %s, %s, %s, %s)"
  14.         cursor.execute(sql, ('Rabbit', '0', '35', '20000', '5', '10000', '1000'))
  15.         connection.commit()    
  16.     pass    
  17.  
  18. def read_data():
  19.     with connection.cursor() as cursor:
  20.         sql = "SELECT `id`, `name`, `sex`, `age` FROM `main`"    
  21.         cursor.execute(sql, ())
  22.         result = cursor.fetchone()
  23.         print(result)
  24.     pass
  25.  
  26.  
  27. #new_user()  
  28. read_data()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement