예제 #1
0
def delDbSource(db_source_ids):
    sql = None
    if len(db_source_ids) == 1:
        sql = "update db_source set del_flag=1 where id='%s'" % db_source_ids[0]
    elif len(db_source_ids) > 1:
        temp_ids = []
        for id in db_source_ids:
            temp_ids.append(id.encode(encoding='utf-8'))
        sql = "update db_source set del_flag=1 where id IN%s" % str(
            tuple(temp_ids))
    BaseDao.execute(sql)
예제 #2
0
파일: ad.py 프로젝트: ldw0810/Crawler
def get_result(table_name, field_name, field_id):
    sql = """select %s from %s where id='%s'""" % (field_name, table_name,
                                                   field_id)
    result = BaseDao.execute(sql)
    if result and len(result.cursor._rows) > 0:
        return result.cursor._rows[0][0]
    return False
예제 #3
0
 def isTableExist(self,tablename):
     sql = """
         SHOW TABLES LIKE '%s'
     """ % tablename
     rs =BaseDao.execute(sql)
     if(rs.rowcount == 1):
         return True
     else:
         return False
예제 #4
0
def queryAllTempByTaskField(taskJobId):

    taskJobReTemplate = Session.query(TaskJobReTemplate).filter(TaskJobReTemplate.taskJobId == taskJobId).first()
    result = None
    if taskJobReTemplate is not None:
        jobTemplate = Session.query(JobTemplate).filter(JobTemplate.id == taskJobReTemplate.jobTemplateId).first()
        jobTemplate1 = Session.query(JobTemplate).filter(JobTemplate.parentId == jobTemplate.id).first()
        sql = "select w1.wechatImage,w1.detailURL,w3.title,w3.time,w3.organization from %s w1 join %s w3 on w1.id=w3.parent_id" % (jobTemplate.tableName,jobTemplate1.tableName)
        result = BaseDao.execute(sql)
        if result and len(result.cursor._rows) > 0:
            result= result.cursor._rows
    return {'result':result,'count':[[len(result)]]}
예제 #5
0
def is_dbsource_in_using(dbsource_id):
    """
    判断数据源是否正在使用中
    :param dbsource_id: 
    :return: 
    """
    try:
        s = """select * from db_source d where d.ID IN (select j.database_id from job_template as j where j.del_flag=0 and j.database_id="%s" UNION SELECT t.database_id from task_job t where t.del_flag=0 and t.database_id="%s")""" % (
            dbsource_id, dbsource_id)
        result = BaseDao.execute(s)
    except Exception, e:
        logging.exception(str(e))
        return False