Exemplo n.º 1
0
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;
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def photogalleries(table):
    '''Convert table with info about photogalleries to MongoDB'''
    sql_cursor.execute("SELECT * FROM " + table)
    db['photogalleries'].insert( sql_cursor.fetchall() )