필터 지우기
필터 지우기

from timetable to mysql database

조회 수: 3 (최근 30일)
Marco Laiolo
Marco Laiolo 2024년 3월 18일
댓글: Marco Laiolo 2024년 3월 29일
Hi all,
I routinely automatic timetable every X minutes at the end of data processing all with matlab 2023b. I have a mysql database that, currently, i update setting colheaders and alllcolumn variables (double or string or datetime).
I see that sqlwrite don't work with timetable; someone know other function or strategy to write timetable (with colheader) directly in a already created mysql table that have the same column and header name of the timetable?
Thanks
Marco

답변 (1개)

Samay Sagar
Samay Sagar 2024년 3월 25일
As mentioned in the MathWorks documentation, “sqlwrite” supports only insertion of “table” data type in a database. However, you can insert a “timetable” in SQL database by employing a workaround by converting your “timetable” to “table” using “timetable2table” function. After converting your timetable to a table, ensure the column names exactly match those in your MySQL table. If your timetable includes a “Time” column (which is automatically created during the conversion), and your MySQL table uses the same column name for time/date data, you're all set. If not, you might need to adjust the column names in your MATLAB table to align with your MySQL schema.
Read more about “timetable2table” and “sqlwrite” here:
  댓글 수: 2
Marco Laiolo
Marco Laiolo 2024년 3월 28일
Thank you very much , Samay...great and it works!
Marco Laiolo
Marco Laiolo 2024년 3월 29일
However, it seems that if in the TABLE there is an already write row (with the same) the command sqlwrite don't work
this tis the message
JDBC Error: Duplicate entry .... for key 'time' (my firstrow after id)
even if I set "unique" on my variable time in mysql db.It's a my problem or someone know this.
Thanks a lot

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by