How to send data from Matlab to MySQL?

6 views (last 30 days)
Beatrice Sonzogni
Beatrice Sonzogni on 2 Jul 2021
Commented: dpb on 2 Jul 2021
Hi, we need to send some data from matlab code to MySQL database, but using 'sqlwrite' we receive this kind of error: "ODBC Error: ODBC Driver Error: ."
Can someone give us an advice? Thank you in advance.
Here the code used:
colnames = {'ID_code','bolus','time'};
data_prova = {id, bolo, time3};
datatable = cell2table(data_prova, 'VariableNames',colnames)
sqlwrite(conn,'output', datatable);
  3 Comments
dpb
dpb on 2 Jul 2021
I don't have so can't do any testing, but I see from the doc for sqlwrite that the syntax is
sqlwrite(conn,tablename,data)
where
conn is the connection object (that is undefined in the code snippet above, but I'll presume that's just because it was omitted in the post, not that forgot to open it),
tablename is the database table name which must be either char or string variable -- and your variable data_prova may or may not be a valid name; that's indeterminate as we can't see what the three variables making it up are, and
data is a table. There are caveats on what data types are a valid table as well.
So, of all the variables, we can't verify any from the information posted....it could be simply "operator error" or it may be something deeper.
It is frustrating when ODBC or ActiveX or whatever gives such useless error messages though, I'll agree wholeheartedly.

Sign in to comment.

Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!