예제 #1
0
파일: tomongo.py 프로젝트: ZloyZ/wiki9
def articles():
    '''Convert all content that have dataset set to 2 from MySQK to MongoDB'''

    data = [];
    for content in db['content'].find({'settings.dataset': '2'}):
        data += [content['path']];
        table = content['settings'].get('table', None);
        if table is None: continue;
        sql_cursor.execute("SELECT full FROM " + table)
        full = sql_cursor.fetchone()['full'];

        update = {
                "$set" : {"data_html": full},
                 }
       
        db['content'].update({"_id": content["_id"]}, update);
#            sql_cursor.execute("DROP TABLE " + table + ";");
 #       except:
  #          pass

    return data;
예제 #2
0
파일: tomongo.py 프로젝트: ZloyZ/wiki9
def graduates(table_years, table, cid):
    '''Convert graduates database'''
    sql_cursor.execute("SELECT * FROM " + table_years)
    years= []
    yearbyid = {}
    
    for row in sql_cursor.fetchall():
        y = int(row['year'])
        yearbyid[row['id']] = y
        years += [y]

    sql_cursor.execute("SELECT * FROM " + table)
    graduates = sql_cursor.fetchall()

    for student in graduates:
        student['year'] = yearbyid[student['parent']]
        del student['parent']
        del student['precedence']

    db['content'].update({'id':cid}, {"$set" : {"data_years" : years} })
    db['graduates'].insert(graduates);
    return graduates
예제 #3
0
파일: tomongo.py 프로젝트: ZloyZ/wiki9
def photogalleries(table):
    '''Convert table with info about photogalleries to MongoDB'''
    sql_cursor.execute("SELECT * FROM " + table)
    db['photogalleries'].insert( sql_cursor.fetchall() )