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