Importing data from a database
Very often, our work on data analysis and visualization is at the consumer end of the data pipeline. We most often use the already produced data, rather than producing the data ourselves. A modern application, for example, holds different datasets inside relational databases (or other databases), and we use these databases and produce beautiful graphs.
This recipe will show you how to use SQL drivers from Python to access data.
We will demonstrate this recipe using a SQLite database because it requires the least effort to setup, but the interface is similar to most other SQL-based database engines (MySQL and PostgreSQL). There are, however, differences in the SQL dialect that those database engines support. This example uses simple SQL language and should be reproducible on most common SQL database engines.
Getting ready
To be able to execute this recipe, we need to install the SQLite library.
$ sudo apt-get install sqlite3
Python support for SQLite is there by...