Question: Write a python script that is going to create your tables from Part 1 (see below) and populate them with data automatically. Use sqlite3 database

Write a python script that is going to create your tables from Part 1 (see below) and populate them with data automatically. Use sqlite3 database as shown in class and make the necessary data type changes in your DDL from part1 (e.g., NUMBER(5,0)INTEGER, NUMBER(5,2)REAL). Your python code must successfully load data into all tables (however many tables you have created in Part-1). Note that you are loading data into SQLite, not into Oracle (the process is the same, but installing cx_Oracle for python is somewhat complicated). Your python code must read the input file data_hw2.txt (see below)directly and automatically load the data. Manually creating INSERT SQL statements will not count for credit in this part.

Tables:

CREATE TABLE Person(

First VARCHAR(20) NOT NULL,

Last VARCHAR(20) NOT NULL,

Address VARCHAR(50),

CONSTRAINT pk_Person PRIMARY KEY(First, Last)

);

CREATE TABLE Job(

JobTitle VARCHAR(20) PRIMARY KEY,

Salary DECIMAL,

Assistant BOOLEAN

);

input file data_hw2.txt:

John, Smith, 111 N. Wabash Avenue, plumber, 40K, NULL John, Smith, 111 N. Wabash Avenue, bouncer, 35K, NULL Jane, Doe, 243 S. Wabash Avenue, waitress, 50K, NULL Jane, Doe, 243 S. Wabash Avenue, accountant, 42K, Yes Jane, Doe, 243 S. Wabash Avenue, bouncer, 35K, NULL Mike, Jackson, 1 Michigan Avenue, accountant, 42K, Yes Mike, Jackson, 1 Michigan Avenue, plumber, 40K, NULL Mary, Who, 20 S. Michigan Avenue, accountant, 42K, Yes Mary, Who, 20 S. Michigan Avenue, risk analyst, 80K, Yes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!