from timetable to mysql database

4 Ansichten (letzte 30 Tage)
Marco Laiolo
Marco Laiolo am 18 Mär. 2024
Kommentiert: Marco Laiolo am 29 Mär. 2024
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

Antworten (1)

Samay Sagar
Samay Sagar am 25 Mär. 2024
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 Kommentare
Marco Laiolo
Marco Laiolo am 28 Mär. 2024
Thank you very much , Samay...great and it works!
Marco Laiolo
Marco Laiolo am 29 Mär. 2024
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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by