`Select * from table where ='something '`return 如果没有选择数据,游标是什么意思
What does a cursor for `Select * from table where ='something '`return if no data is selected
我想知道什么是 Select 查询 return 如果没有选择任何行,它会是 NULL 还是其他:
eq
cursor.execute(Select * from table where data= "YES")
当查询 returns 数据时,以下适用:
import MySQLdb
conn = MySQLdb.Connection(...)
curs = conn.cursor()
print curs.execute("select * from cities where city like 'San %'")
51 //51 rows found
rows = curs.fetchall()
print len(rows)
51 // as stated above 51 rows found
然而,如果您的查询 return 0 行,您将得到一个空列表
if not rows:
# empty set returned
我想知道什么是 Select 查询 return 如果没有选择任何行,它会是 NULL 还是其他:
eq
cursor.execute(Select * from table where data= "YES")
当查询 returns 数据时,以下适用:
import MySQLdb
conn = MySQLdb.Connection(...)
curs = conn.cursor()
print curs.execute("select * from cities where city like 'San %'")
51 //51 rows found
rows = curs.fetchall()
print len(rows)
51 // as stated above 51 rows found
然而,如果您的查询 return 0 行,您将得到一个空列表
if not rows:
# empty set returned