python/ mysql
Second last line is showing error <Unread.result.found> but when i run it individually it run successfully
import mysql.connector as msqc
import numpy as np
db = msqc.connect(
host="localhost",
username="root",
password=" ",
database="hotel",
)
cur = db.cursor()
ss = 'SELECT one_bed ,Available_one_bed from rooms where Available_one_bed = "A" '
cur.execute(ss)
available_room = cur.fetchone()
print(available_room[0])
cur.execute('SELECT * from rooms')
s = 'UPDATE rooms SET Available_one_bed = "N/A" WHERE one_bed = '+str(100)
cur.execute(s)
Most likely not all data where read after first execute. You need a buffered cursor, eg
cur = db.cursor(buffered=True)
some details could be found here https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursorbuffered.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.