文章内容
2019/3/3 16:14:33,作 者: 黄兵
MySQLCursor.fetchone() Method
fetchone(): 该方法获取下一个查询结果集。结果集是一个对象
具体实例如下:
def get_token(phone_number): conn_config = Conn_Config() db = conn_config.Conn_MySQL() cursor = db.cursor() sql = "SELECT t.Token FROM phonenumber_list l inner join tokenlist t on l.id = t.PhoneNumber_id where l.PhoneNumber= %s;" \ % (phone_number) # 执行SQL语句 cursor.execute(sql) row = cursor.fetchone() while row is not None: token = row[0] return token
参考资料:
评论列表