Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- connection = pymysql.connect(host='localhost',
- user='root',
- password='password',
- db='blog',
- charset='utf8',
- cursorclass=pymysql.cursors.DictCursor)
- with connection.cursor() as cursor:
- # Read a single record
- sql = "SELECT * from categories"
- cursor.execute(sql)
- result = cursor.fetchall()
- print(result)
- connection.close()
- #do other thins ..............................
- #maby return here and do not execute below
- #occur error below
- with connection.cursor() as cursor:
- # Read a single record
- sql = "SELECT * from categories"
- cursor.execute(sql)
- result = cursor.fetchall()
- print(result)
Add Comment
Please, Sign In to add comment