Exercise: Databases
Practice data extraction by extracting customer and product-related data from both MySQL and PostgreSQL.
We'll cover the following
Example
Suppose we’re data analysts working for a retail company and our task is to extract customer and product-related data from two relational databases: MySQL and PostgreSQL. The customer data is stored in MySQL, while the product data is stored in PostgreSQL. The company is interested in focusing its marketing budget on marketing the most expensive products to customers from the USA.
We’ve decided to use Python to connect to both databases, extract the required data, and export it as CSV files to accomplish the task.
Note: Fill in the missing code in the highlighted rows in the code widgets to complete the tasks.
Extracting customer data from MySQL
The first task is to extract data from the customers
table from MySQL. The marketing department is interested in marketing to clients from the USA. So, the first task is to extract customers whose country
is equal to 'USA'
.
Get hands-on with 1400+ tech skills courses.