Answer the question
In order to leave comments, you need to log in
matlab. Import data from DBMS blob fields. In particular from MS SQL?
I have been working with MATLAB recently. Installed version R2017a. The general task is image analysis. When working with files - no questions arise, everything works fine. But millions of images will have to be processed. They are contained in MS SQL, in the blob field, in the form of JPG files. For the test, I tried to import 300 records using the Database Explorer wizard. The ODBC driver used is SQL Server Native client 11.0. Everything is simple and wonderful. I get Cell Array 300x2 cell. The record number and the drawing itself. When viewing, it is clear that the dimensions of the images are different:
20243x1 uint8
19020x1 uint8, etc.
I worked - I was convinced - everything is fine: the photos are excellent.
Using the same DataBase Explorer, I generated a data import script:
%Set preferences with setdbprefs.
setdbprefs('DataReturnFormat', 'cellarray');
setdbprefs('NullNumberRead', 'NaN');
setdbprefs('NullStringRead', 'null');
%Make connection to database. Note that the password has been omitted.
%Using ODBC driver.
conn = database('Test10', 'user', 'pass');
%Read data from database.
curs = exec(conn, ['SELECT RecID, Image FROM Images'];
curs = fetch(curs);
close(curs);
%Assign data to output variable
ImpData = curs.Data;
%Close database connection.
close(conn);
%Clear variables
clear curs conn
Answer the question
In order to leave comments, you need to log in
Today I managed to find a solution that worked, but the questions still remained.
Since the question was asked, I have changed my computer, OS, and version of MATLAB.
OS - Windows 10
MATLAB - 9.5.0.944444 (R2018b)
The solution was found in the type of ODBC driver used.
I currently have the following installed:
In theory, each of these drivers should give a normal result, but only
the MS SQL driver, marked in the screenshot, worked for me. All the others give a truncated result of data up to 8000, but the specified one gave this data:
6143047 5999x1 uint8
224233 24889x1 uint8
4200382 6130x1 uint8
13687913 28456x1 uint8
2212046 8511x1 uint8
8346866 6400x1 uint8
1305479 6760x1 uint8
7806085 6641x1 uint8
6851834 7164x1 uint8
7084710 6550x1 uint8
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question