Unreadable or empty strings when connecting to an MySQL database with Database Explorer App or command line
2 次查看(过去 30 天)
显示 更早的评论
I succesfully connecter the Database Explorer App to a MySQL database that I created on a virtual machine to run some test.
Here you can see the content of the database.
The problem is that when I try to read the data from Matlab I get unreadable strings that change every time I run the query (if I use the app) or empty cells (if I use command line). See the following screenshots.
What am I missing?
Thank you
0 个评论
回答(1 个)
Piyush Dubey
2023-9-4
Hi Luca,
I can understand that you are able to connect your SQL database to MATLAB using Database Explorer App but while trying to get data from your SQL database, the records having datatype of ‘varchar’ are not getting read in their actual form but are being read as empty strings {0x0 char}.
Please know that in this scenario, there are two languages interacting and interfacing each other and it is likely that a datatype compatible with the source language is not compatible with the target language. Conversion of datatype from source to the target language may not be performed implicitly when fetched from a different programming language and there might be a need to explicitly specify the datatype in which the data is to be imported in the target language which is MATLAB in this case.
Please refer the following MathWorks documentation link that provides with “Data Type support” of various databases with MATLAB:
Besides, “fetch” command can be used after connection is established. It also provides various “SQLImportOptions”.
You can refer this documentation for more information on “fetch” command:
I hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!