Question: In PYTHON 1) Create a function read_query that takes a file name as input, reads the file, and returns the contents of the file as

In PYTHON

1) Create a function read_query that takes a file name as input, reads the file, and returns the contents of the file as a string. See the tasks in the lab.

2) Create a function execute_query that takes a MySQL query, database name, username, and password as input, and then connects to the database, executes the query, and returns the results.

3) The main program will read in a file, read the MySQL query contained in the file, execute the query, and print the results (one row at a time) of the query.

4) The database, username, password, and filename must be obtained from the system arguments: python read_execute.py database username password query1.sql

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!