Chapter 23. Saving data

 

This chapter covers

  • Storing data in relational databases
  • Using the Python DB-API
  • Accessing databases through an Object Relational Mapper (ORM)
  • Understanding NoSQL databases and how they differ from relational databases

When you have data and have it cleaned, it’s likely that you’ll want to store it. You’ll not only want to store it, but also be able to get at it in the future with as little hassle as possible. The need to store and retrieve significant amounts of data usually calls for some sort of database. Relational databases such as PostgreSQL, MySQL, and SQL Server have been established favorites for data storage for decades, and they can still be great options for many use cases. In recent years, NoSQL databases, including MongoDB and Redis, have found favor and can be very useful for a variety of use cases. A detailed discussion of databases would take several books, so in this chapter I look at some scenarios to show how you can access both SQL and NoSQL databases with Python.

23.1. Relational databases

23.2. SQLite: Using the sqlite3 database

23.3. Using MySQL, PostgreSQL, and other relational databases

23.4. Making database handling easier with an ORM

23.5. NoSQL databases

23.6. key:value stores with Redis

23.7. Documents in MongoDB

Summary

sitemap