Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (20 points) Writing data to an SQLite database Locate the dataset named IMDbmovies.csv on Canvas. Use Python code to create a database named cse2050_movies_db.db.

image text in transcribed
1. (20 points) Writing data to an SQLite database Locate the dataset named IMDbmovies.csv on Canvas. Use Python code to create a database named cse2050_movies_db.db. Next, create a table named imdb_movies in your database and insert the data from the CSV file into the imdb_movies table. (Hints: using aqlite3.connect will create the database if it doesn't exist. Read the CSV line by line and pull out each record, clean, and write each record to the database table) You may use the following data-types for your table: imdb_movies indb_title_id VARCHAR(10) title VARCHAR(500) original title VARCHAR(250) year INTEGER date_published DATE genre VARCHAR(200) duration INTEGER country VARCHAR(100) language VARCHAR(50) director VARCHAR(250) writer VARCHAR(250) production company VARCHAR(250) actors TEXT description TEXT avg_vote REAL votes INTEGER budget INTEGER usa-gross income INTEGER vorlwide_gross_income INTEGER setascore INTEGER reviews_from_users INTEGER reviews_from_critica INTEGER Note that certain fields will need cleaning before insertion. For example, the indb_title_id resembles the following: tt0000009. Remove the "" from the value Similarly, fields like budget, usa gross income, and worldwide_gross_incone contain commas, dollar signs and other characters, which must be removed for the values to be stored as integers. As an example, opening your imdb_movies table in your database using the SQLite Browser should resemble the following Figure 1: Snapshot of the imdb movies table 1. (20 points) Writing data to an SQLite database Locate the dataset named IMDbmovies.csv on Canvas. Use Python code to create a database named cse2050_movies_db.db. Next, create a table named imdb_movies in your database and insert the data from the CSV file into the imdb_movies table. (Hints: using aqlite3.connect will create the database if it doesn't exist. Read the CSV line by line and pull out each record, clean, and write each record to the database table) You may use the following data-types for your table: imdb_movies indb_title_id VARCHAR(10) title VARCHAR(500) original title VARCHAR(250) year INTEGER date_published DATE genre VARCHAR(200) duration INTEGER country VARCHAR(100) language VARCHAR(50) director VARCHAR(250) writer VARCHAR(250) production company VARCHAR(250) actors TEXT description TEXT avg_vote REAL votes INTEGER budget INTEGER usa-gross income INTEGER vorlwide_gross_income INTEGER setascore INTEGER reviews_from_users INTEGER reviews_from_critica INTEGER Note that certain fields will need cleaning before insertion. For example, the indb_title_id resembles the following: tt0000009. Remove the "" from the value Similarly, fields like budget, usa gross income, and worldwide_gross_incone contain commas, dollar signs and other characters, which must be removed for the values to be stored as integers. As an example, opening your imdb_movies table in your database using the SQLite Browser should resemble the following Figure 1: Snapshot of the imdb movies table

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions