Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a python function that takes the name of a SQL table as parameter and then does the following: Select all rows from that table

Write a python function that takes the name of a SQL table as parameter and then does the following:

Select all rows from that table (you can assume that the table already exists in SQLite) with all attributes from that table and output to a file a sequence of corresponding INSERT statements, one for each row from the table. Think of this as an export tool, since these INSERT statements could now be executed in Oracle (you do not need to actually execute them in Oracle that).

For example: generateInsertStatements('Students') should write to a file an insert statement from each row contained in the Students table (assuming the table is in SQLite already)

inserts.txt:

INSERT INTO Students VALUES (1, Jane, A-); INSERT INTO Students VALUES (1, Mike, B); INSERT INTO Students VALUES (1, Jack, B+);

Hint: as you iterate through the rows of the given table, instead of printing the output, you will want to write an INSERT SQL statement to an output file each time.

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

Describe limit orders and market orders.

Answered: 1 week ago

Question

2. What potential barriers would you encourage Samuel to avoid?

Answered: 1 week ago