import threading,cx_Oracle
from time import sleep
from MainAction import StartClass
class controlclass(object):
def init(self,startflag,user='hr',pwd='687092',ipname='192.168.#####/###'):
self.startflag = startflag
self.conn = cx_Oracle.connect(user, pwd, ipname)
self.cursor = self.conn.cursor()
def __str__(self):
return self.startflag
def __call__(self):
if self.startflag == '1':
sql = 'SELECT t.taskid,t.circlestype FROM d_task t where t.circlestype=\'2\''
try:
while True:
main_object = self.cursor.execute(sql)
print(main_object)
if main_object is None:
print('查询主任务是否有循环启动状态的SQL错误')
elif len(main_object) == 0:
print('没有循环启动的主任务')
else:
print('返回查看满足状态的主任务')
sleep(1)
except Exception as x:
print('单条SQL执行(查询SQL)失败')
print(x)
print(sql)
self.cursor.close()
self.conn.close()
if name == '__main__':
cs = controlclass('1')
cs()
>
单条SQL执行(查询SQL)失败
object of type 'cx_Oracle.Cursor' has no len()
SELECT t.taskid,t.circlestype FROM d_task t where t.circlestype='2'