I need a script to store the values of mysql statement . Below is the snippet I wrote .
the below command works for last 2 answer but not the first one .
Note :- In mysql, the online_status column contains 3 type of values i.e. 0,1 or NULL .
Thanks and regards
>>import pymysql >>username='kbr_dev' >>sel_query=("select name,online_status from user where name = '%s' " %(username)) >>mysqlconnnect_test = pymysql.connect(host = 'localhost', user = 'root', password='root123', db='dev') >>cursor = mysqlconnect_test.cursor() >>cursor.execute(sel_query) >>records = cursor.fetchall() >>print(records)With the above code, I get 3 type of result with different username .
(('kbr_dev', None),) (('kbr1_dev', '\x01'),) (('kbr2_dev', '\x00'),)How to store the 2nd value (None/00/01) to a variable.
the below command works for last 2 answer but not the first one .
>>ord(records[0][1])Any help is highly appreciable .
Note :- In mysql, the online_status column contains 3 type of values i.e. 0,1 or NULL .
Thanks and regards