def d_insert_org_tutorial():
    #step 1: get all the id of original tutorials
    tutorials_id = get_id.get_id()

    #set up database
    con = mdb.connect(host="mysql1", user="******", passwd="TBtsTL4Xn6e4Whwh", db="khandb");
    cur = con.cursor()
    #delete all data in org_tutorial table
    #cur.execute("DELETE FROM org_tutorials")
    #get all records 
    cur.execute("SELECT org_tut_id FROM org_tutorials")
    results = cur.fetchall()
    
    for t_id in tutorials_id:
        #step 2: get all the name of original tutorials
        count = 0
        #print "--------------------------------------"
        #print t_id
        for org_tut_id in results:
            org_tut_id = str(org_tut_id)[1:][:-3]
            print org_tut_id
            if org_tut_id == t_id:
                count = 1
        #print count
        #print "***************************************"
        if count != 1:
            t_name = get_name.get_name(t_id)
            #step 3: insert id and name into org_tutorial table
            #database
            #insert new data
            cur.execute("INSERT INTO org_tutorials (org_tut_id, org_tut_name, inserted_time) VALUES (%s, %s, now())",(t_id, t_name))
    
    con.close()
Example #2
0
def main():
    #step 1: get all the id of original tutorials
    tutorials_id = get_id.get_id()
    
    for t_id in tutorials_id:
        #step 2: get all the name of original tutorials
        t_name = get_name.get_name(t_id)
        
        #step 3: insert id and name into org_tutorial table
        #database
        
        #step 4: From the result of step 3, call get_name to first level totorial info
        get_spinoff.get_first_spinoff(t_id)
        
        #step 5: Insert into first_level_spinoff table
        #database
        
        #step 6: From the result of step 5, call get_user_id to get user id
        user_id = get_user_id.get_user_id(t_id)

        #step 7: insert user info into user table
        #database

        #step 8: Call get_user_project to get all related project
        get_user_project.get_user_project(user_id)
def d_insert_org_tutorial():
    #step 1: get all the id of original tutorials
    tutorials_id = get_id.get_id()

    #set up database
    con = mdb.connect(host="mysql1", user="******", passwd="TBtsTL4Xn6e4Whwh", db="khandb");
    cur = con.cursor()
    #delete all data in org_tutorial table
    cur.execute("DELETE FROM org_tutorials")
    
    for t_id in tutorials_id:
        #step 2: get all the name of original tutorials
        t_name = get_name.get_name(t_id)

        #step 3: insert id and name into org_tutorial table
        #database
        #insert new data
        cur.execute("INSERT INTO org_tutorials (org_tut_id, org_tut_name) VALUES (%s, %s)",(t_id, t_name))
    
    con.close()
Example #4
0
def main():
    #step 1: get all the id of original tutorials
    tutorials_id = get_id.get_id()

    #set up database
    con = mdb.connect(host="mysql1", user="******", passwd="TBtsTL4Xn6e4Whwh", db="khandb");
    cur = con.cursor()
    #delete all data in org_tutorial table
    cur.execute("DELETE FROM org_tutorials")
    
    for t_id in tutorials_id:
        #step 2: get all the name of original tutorials
        t_name = get_name.get_name(t_id)

        #step 3: insert id and name into org_tutorial table
        #database
        #insert new data
        cur.execute("insert into org_tutorials (org_tut_id, org_tut_name) values (%s, %s)",(t_id, t_name))
        
        #step 4: From the result of step 3, call get_name to first level totorial info
        #get_spinoff.get_first_spinoff(t_id)
        
        #step 5: Insert into first_level_spinoff table
        #database
        
        #step 6: From the result of step 5, call get_user_id to get user id
        #user_id = get_user_id.get_user_id(t_id)

        #step 7: insert user info into user table
        #database

        #step 8: Call get_user_project to get all related project
        #get_user_project.get_user_project(user_id)
        
        #step 9: go back to step 4 for three times (second & third level)
    
    con.close()