Unreadable or empty strings when connecting to an MySQL database with Database Explorer App or command line
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Piyush Dubey
le 4 Sep 2023
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 commentaires
Voir également
Catégories
En savoir plus sur Database Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!