def init(): initialize_logger(os.getcwd()) coloredlogs.install(level='DEBUG') coloredlogs.ColoredFormatter() c = Cassandra() syncTables() g = Goodreads() return (c, g)
shelves=[] for s_v_c in elem[1:]: svc_array=s_v_c.replace("(", "").replace(")","").split(",") #print svc_array[0] #Shelve #print int(svc_array[1]) #Votes #print int(svc_array[2]) #Counts shelves.append(Shelve(svc_array[0], int(svc_array[1]), int(svc_array[2]))) insert_statement = c.getSession().prepare("UPDATE prs.recommendation SET most_common_shelves = ?, common_shelves_retrieved= ? WHERE id= ?") c.getSession().execute(insert_statement, [shelves, True, UUID(str(rows[0]['id']))]) def getUserName(c): rows = c.getSession().execute('SELECT id, user_gid FROM prs.recommendation') for row in rows: users=c.getSession().execute('SELECT id, name FROM prs.users WHERE gid=%s', [row['user_gid']]) logging.info("Update username for user %s wth name %s", row['id'], users[0]['name']) c.getSession().execute('UPDATE prs.recommendation SET username = %s WHERE id= %s', [users[0]['name'], row['id']]) if __name__ == "__main__": initialize_logger(os.getcwd()) coloredlogs.install(level='DEBUG') coloredlogs.ColoredFormatter() c=Cassandra() sync_table(models.Books) sync_table(models.Shelves) sync_table(models.Authors) sync_table(models.Users) sync_table(models.Reviews) sync_table(models.Recommendation) setCommonShelveretrieved(c)
c.getSession().execute( insert_statement, [shelves, True, UUID(str(rows[0]['id']))]) def getUserName(c): rows = c.getSession().execute( 'SELECT id, user_gid FROM prs.recommendation') for row in rows: users = c.getSession().execute( 'SELECT id, name FROM prs.users WHERE gid=%s', [row['user_gid']]) logging.info("Update username for user %s wth name %s", row['id'], users[0]['name']) c.getSession().execute( 'UPDATE prs.recommendation SET username = %s WHERE id= %s', [users[0]['name'], row['id']]) if __name__ == "__main__": initialize_logger(os.getcwd()) coloredlogs.install(level='DEBUG') coloredlogs.ColoredFormatter() c = Cassandra() sync_table(models.Books) sync_table(models.Shelves) sync_table(models.Authors) sync_table(models.Users) sync_table(models.Reviews) sync_table(models.Recommendation) setCommonShelveretrieved(c)