addCamera.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:CAM2RetrieveData 作者: PurdueCAM2Project 项目源码 文件源码
def insert_into_camera(sourceName,cameraType,db):
    print '---------------------------------------------------------------------------------'
    print "STEP 4 : Load camera table from info_source where source = '%s'"%sourceName
    print "Is this camera traffic camera? (y/n) if it is traffic camera, is_safe will be 1"
    print "otherwise, 0"
    print '---------------------------------------------------------------------------------'
    isSuccess = True
    cursor = db.cursor()
    yn = raw_input()
    if yn == 'y' or 'Y':
        sql = "INSERT IGNORE INTO camera (camera_key, encrypted_camera_key, type, source, latitude, longitude, country, state, city, resolution_width, resolution_height, frame_rate, is_video, is_active, is_safe, is_high_load, is_analysis_restricted, utc_offset, timezone_id, timezone_name, reference_logo, reference_url,multiple_cameras,is_located,weather_wind_speed,weather_temperature_faren,weather_humidity,weather_code) SELECT snapshot_url, null, %s, source, latitude, longitude, country, state, city, null, null, null, 0, 1, 1, 0, 0, null, null, null, null, null, null, 1, null, null, null, null FROM info_source WHERE source=%s"%(("'"+cameraType+"'","'"+sourceName+"'"))
    else:
        sql = "INSERT IGNORE INTO camera (camera_key, encrypted_camera_key, type, source, latitude, longitude, country, state, city, resolution_width, resolution_height, frame_rate, is_video, is_active, is_safe, is_high_load, is_analysis_restricted, utc_offset, timezone_id, timezone_name, reference_logo, reference_url,multiple_cameras,is_located,weather_wind_speed,weather_temperature_faren,weather_humidity,weather_code) SELECT snapshot_url, null, %s, source, latitude, longitude, country, state, city, null, null, null, 0, 1, 0, 0, 0, null, null, null, null, null, null, 1, null, null, null, null FROM info_source WHERE source=%s"%(("'"+cameraType+"'","'"+sourceName+"'"))
    try:
        print "Inserting into camera table from info_source"
        cursor.execute(sql)
        cursor.execute("select * from info_source where source = "+"'"+sourceName+"'")
        num_record=cursor.rowcount
        cursor.execute("select * from camera where source = "+"'"+sourceName+"'")
        num_table = cursor.rowcount
        print "%d recorded in camera out of %d from info_source"%(int(num_table),int(num_record))
    except MySQLdb.Error, e:
        print "MySQL Error [%d]: %s" % (e.args[0], e.args[1])
        isSuccess = False
    except MySQLdb.Warning,e:
        print "MYSQL Warning : %s"%e
        isSuccess = False

    return isSuccess
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号