Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started