Use a MySQL® native interface database connection to insert product data from MATLAB® into a new table in a MySQL database. Then, reverse the changes made to the database.
Create a MySQL native interface database connection to a MySQL database using the data source name, user name, and password. The database contains the tables productTable
and suppliers
.
Allow manual committing of changes to the database by setting the AutoCommit
property to off
.
Create a MATLAB table that contains data for two products. The data is stored in the productTable
and suppliers
tables.
Insert the product data into a new table named toyTable
.
Import the contents of the database table into MATLAB and display the rows. The results contain two rows for the inserted products.
rows=2×5 table
productNumber stockNumber supplierNumber unitCost productDescription
_____________ ___________ ______________ ________ __________________
30 5e+05 1000 25 "Rubik's Cube"
40 6e+05 2000 30 "Doll House"
Reverse the changes made to the database.
Import and display the contents of the database table again. The results are empty.
Close the database connection.