In [2]:
import mysql.connector as mysql
In [3]:
db = mysql.connect(
        host="localhost",
        database="raj",
        user="raj",
        passwd="r123",
        auth_plugin='mysql_native_password'
      )
In [4]:
capacity = 10
query = '''
    select bcode,rnumber
    from   room
    where  cap <= %s
'''
cursor = db.cursor()
cursor.execute(query,(capacity,))
records = cursor.fetchall()
if len(records) == 0:
    print('No rooms')
else:
    for record in records:
        print(record[0], record[1])
NSC 249
NSC 528
NSC 538
In [5]:
t1 = (5)
In [6]:
print(t1)
5
In [7]:
t2 = (5,)
In [8]:
print(t2)
(5,)
In [9]:
t2[0]
Out[9]:
5