Plotting data from a database
Databases often tend to collect much more information than we can simply extract and watch in a tabular format (let's call it the "Excel sheet" report style).
Databases not only use efficient techniques to store and retrieve data, but they are also very good at aggregating it.
One suggestion we can give is to let the database do the work. For example, if we need to sum up a column, let's make the database sum the data, and not sum it up in the code. In this way, the whole process is much more efficient because:
There is a smaller memory footprint for the Python code, since only the aggregate value is returned, not the whole result set to generate it
The database has to read all the rows in any case. However, if it's smart enough, then it can sum values up as they are read
The database can efficiently perform such an operation on more than one column at a time
The data source we're going to query is from an open source project: the Debian distribution. Debian has...