Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql.cursors
- connection = pymysql.connect(host='localhost',
- user='max',
- password='27ChaNel',
- db='kingdom_elementsDB',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- def new_user():
- with connection.cursor() as cursor:
- sql = "INSERT INTO `main` (`name`, `sex`, `age`, `money`, `fields`, `enemyes`, `warriors`) VALUES (%s, %s, %s, %s, %s, %s, %s)"
- cursor.execute(sql, ('Rabbit', '0', '35', '20000', '5', '10000', '1000'))
- connection.commit()
- pass
- def read_data():
- with connection.cursor() as cursor:
- sql = "SELECT `id`, `name`, `sex`, `age` FROM `main`"
- cursor.execute(sql, ())
- result = cursor.fetchone()
- print(result)
- pass
- #new_user()
- read_data()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement