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

Step: 3

blur-text-image

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 Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

What is a static budget?

Answered: 1 week ago

Question

What are some of the major uses of T-1 lines?

Answered: 1 week ago