Reference no: EM132212199
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 (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.