connect database to matlab

조회 수: 1 (최근 30일)
kareem hassan
kareem hassan 2020년 7월 3일
답변: Piyush Kumar 2024년 9월 27일
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

답변 (1개)

Piyush Kumar
Piyush Kumar 2024년 9월 27일
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.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by