Needs help with this program
Note** Please make up and use any Server: ,User:, Password:, Database Name., (Make up any missing data)
The program will need to do the following:
1. Take an argument from the command-line to specify interactive mode , load a file into the database, write the results of a query/queries to a file, drop a table, create table based on some file.
a. Interactive mode will operate like the mysql program where it reads from standard input to get queries from a user.
b. Loading a file takes an additional argument of the file and load into the database.
c. Writing a file takes two additional arguments of the input and output file
d. Dropping a table takes an additional argument of the table name.
e. Creating a table takes an additional argument of the file specifying the table that the program will create.
2. The program will need to use the argument to determine its execution path.
a. The program will need to connect to the database.
3. Interactive mode
a. Continue to run unless the user enters "quit" or reaches logical end-of-file
b. Take a user input and make it a query
c. Execute the query
d. Access and format the results
e. Display the results to the user
4. Load a file (-L):
a. Parse the supplied file.
i. Note: it can be safely assumed any file give will be structured the same, but values can be different.
b. Generate a query to insert the file's contents into the database
c. Execute the query
5. Create table (-C):
a. Parse the supplied file
i. Note: it can be safely assumed any file give will be structured the same, but values can be different (first column is table then columns formatted as attribute:value for some arbitrary number of columns).
b. Generate a query to insert the file's contents into the database
c. Execute the query
6. Drop a table (-D):
a. Generate a query to drop a table specified based on the command-line argument after -D
b. Execute the query
7. Write data to file
a. Read each line from the supplied file
i. Note: this file will include several queries and should execute all queries
b. Build a query from the line
c. Execute the query
d. Write the results of the query to an output file
i. Do NOT write empty results
8. Exception handling:
a. Use a similar approach as seen in the lab sample code to appropriate capture the parse exception
load_input.csv file contains
muid_tmpid:1pname:'ProductX'price:12category:'2'manufacturer:'a'
muid_tmpid:2pname:'ProductY'price:12.99category:'2'manufacturer:'b'
muid_tmpid:3pname:'ProductZ'price:1299category:'3'manufacturer:'c'
create_input.csv file
table:muid_myTable1id:int:not_null:keypname:varchar(15):not_nullprice:float:not_nullregion:char(4)
table:muid_myTable2id:int:not_null:keypname:char(15):not_nullprice:float:not_nullregion:char(4):not_null
table:muid_myTable3id:int:not_null:keypname:char(15):not_nullprice:intregion:char(4):not_null
table:muid_myTable4id:intpname:char(15):not_nullprice:intregion:char(4):not_null
table:muid_myTable5id:int:not_nullpname:char(15):not_nullprice:intregion:char(4):not_null
table:muid_myTable5id:int:not_nullpname:char(15):not_null:keyprice:int:not_nullregion:char(4):not_null
write_input.csv files
SELECT * FROM Product;
SELECT cname FROM Company;
SELECT pname FROM Product WHERE price > 100;
SELECT id from Product;
CREATE TABLE tmp1234567890987654321(id int not nullpname char(5) not null);
INSERT INTO tmp1234567890987654321(idpname) VALUES (1'John');
INSERT INTO tmp1234567890987654321(idpname) VALUES (2'Mario');
INSERT INTO tmp1234567890987654321(idpname) VALUES (3'Ben');
INSERT INTO tmp1234567890987654321(idpname) VALUES (4'Chris');
SELECT pnameid FROM tmp1234567890987654321;
SELECT pnameid FROM tmp1234567890987654321 WHERE id > 2 ;
DROP TABLE tmp1234567890987654321;