connect database to matlab

1 visualización (últimos 30 días)
kareem hassan
kareem hassan el 3 de Jul. de 2020
Respondida: Piyush Kumar el 27 de Sept. de 2024
i have database created in mysql and i want to use it in matlab so i used matlab connector ODBC
then i used this code to item file in my database
conn = database('kk2','root','');
curs = exec(conn,'INSERT INTO `item`(`name`) VALUES (`pen`)');
but nothing happend and ther is no error in command window

Respuestas (1)

Piyush Kumar
Piyush Kumar el 27 de Sept. de 2024
If nothing happens and there are no errors, it might mean that the data was inserted successfully but you didn’t receive any confirmation. To ensure everything is working as expected, you can verify the insertion by querying the database to check if the new data is present.
I will suggest to add some condition statements to make sure that the execution was successful -
1.Check Database connection: Ensure that the connection to the database is successful.
conn = database('kk2', 'root', '');
if isopen(conn)
disp('Connection successful');
else
disp(['Connection failed: ' conn.Message]);
end
2. Execute the Query Manually: Before using the query in your script, manually execute it in the MySQL command line or a database management tool to ensure it works as expected.
3. In the script, print the output of "exec" to verify the successful query execution.

Etiquetas

Productos


Versión

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by