connect database to matlab
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Piyush Kumar
am 27 Sep. 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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!