Ingestion considerations
Now that we have decided on a schema for our graph, we can begin to move data from our MySQL relational database to an igraph graph. The subsequent steps detail how to achieve this:
- The first thing we must do is extract the data from our MySQL database and move it over to Python. We can do this using the
query_mysql()
method we wrote previously in this chapter. Now that we know more about the data, and that we have designed a graph schema, we can extract only the columns we need to create our graph:play_query = 'SELECT id, game_name, hours FROM steam_play' play_data = query_mysql(play_query, password=PASSWORD) print(play_data[:10]) purchase_query = 'SELECT id, game_name FROM steam_purchase' purchase_data = query_mysql(purchase_query,password=PASSWORD ) print(purchase_data[:10])
In play_data
, we have information on users, the games they have played, and the time they have spent playing each game. In purchase_data
, we only need...