Borrar filtros
Borrar filtros

from timetable to mysql database

3 visualizaciones (últimos 30 días)
Marco Laiolo
Marco Laiolo el 18 de Mzo. de 2024
Comentada: Marco Laiolo el 29 de Mzo. de 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

Respuestas (1)

Samay Sagar
Samay Sagar el 25 de Mzo. de 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 comentarios
Marco Laiolo
Marco Laiolo el 28 de Mzo. de 2024
Thank you very much , Samay...great and it works!
Marco Laiolo
Marco Laiolo el 29 de Mzo. de 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

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by