Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Graph Data Modeling in Python

You're reading from   Graph Data Modeling in Python A practical guide to curating, analyzing, and modeling data with graphs

Arrow left icon
Product type Paperback
Published in Jun 2023
Publisher Packt
ISBN-13 9781804618035
Length 236 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Gary Hutson Gary Hutson
Author Profile Icon Gary Hutson
Gary Hutson
Matt Jackson Matt Jackson
Author Profile Icon Matt Jackson
Matt Jackson
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Part 1: Getting Started with Graph Data Modeling
2. Chapter 1: Introducing Graphs in the Real World FREE CHAPTER 3. Chapter 2: Working with Graph Data Models 4. Part 2: Making the Graph Transition
5. Chapter 3: Data Model Transformation – Relational to Graph Databases 6. Chapter 4: Building a Knowledge Graph 7. Part 3: Storing and Productionizing Graphs
8. Chapter 5: Working with Graph Databases 9. Chapter 6: Pipeline Development 10. Chapter 7: Refactoring and Evolving Schemas 11. Part 4: Graphing Like a Pro
12. Chapter 8: Perfect Projections 13. Chapter 9: Common Errors and Debugging 14. Index 15. Other Books You May Enjoy

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:

  1. 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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image