python 操作查询mysql数据库 如何判断返回是否为空值?
cam_ID=int(mv_ar_num+mv_m_cam)printcam_IDcam_id=[cam_ID]print"cam_id:%s"%cam_idcur.ex...
cam_ID=int(mv_ar_num+mv_m_cam)
print cam_ID
cam_id=[cam_ID]
print "cam_id:%s"%cam_id
cur.execute("select Cam_ID from Cam_loc_tbl where Cam_ID=%d;"%cam_ID) #//(从数据库中查询cam_ID的值)
cam_rows = cur.fetchall()
for cam_row in cam_rows:
CAM_ID=int(cam_row[0])
print cam_rows
print "mysql__CAM_ID:%s"%CAM_ID
if CAM_ID 不为空:(判断如果不是空值)
print "%s already exists!!!!!"%CAM_ID
#break
else:
print '2222222222222222222'
cam_values=cam_id+cam_value
print cam_values
cur.execute('insert into Cam_loc_tbl values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',cam_values) 展开
print cam_ID
cam_id=[cam_ID]
print "cam_id:%s"%cam_id
cur.execute("select Cam_ID from Cam_loc_tbl where Cam_ID=%d;"%cam_ID) #//(从数据库中查询cam_ID的值)
cam_rows = cur.fetchall()
for cam_row in cam_rows:
CAM_ID=int(cam_row[0])
print cam_rows
print "mysql__CAM_ID:%s"%CAM_ID
if CAM_ID 不为空:(判断如果不是空值)
print "%s already exists!!!!!"%CAM_ID
#break
else:
print '2222222222222222222'
cam_values=cam_id+cam_value
print cam_values
cur.execute('insert into Cam_loc_tbl values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',cam_values) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询