Why does sqlread() not work?

조회 수: 5 (최근 30일)
Alex
Alex 2022년 9월 29일
댓글: Alex 2022년 9월 30일
I am trying to use sqlread() to import data from SQLite. I tried to use the sqlread() function in the following manner, exactly like the documentation examples, and I get the following error "Unrecognized function or variable 'sqlread'". I'm using MATLAB R2021a (sqlread introduced in R2018a).
I was able to import the data by replacing sqlread() with fetch() but I do not understand why sqlread() does not work.
conn = sqlite("path_to_sqlite_db.db", 'readonly');
data = sqlread(conn, "my_table_name");
close(conn);
  댓글 수: 2
Cel Kulasekaran
Cel Kulasekaran 2022년 9월 29일
did conn established correctly? sqlread won't work otherwise.
Alex
Alex 2022년 9월 29일
Yes, conn established correctly. When I replaced sqlread() with fetch(), I was able to get the data, so the connection was working. I tried multiple times as well. Based on the error message, MATLAB does need seem to have sqlread() in the workspace/namespace. i.e. MATLAB does not know sqlread() is a function and I do not know why.

댓글을 달려면 로그인하십시오.

답변 (2개)

Cel Kulasekaran
Cel Kulasekaran 2022년 9월 30일
@Alex, Walter is sort of right.
If you want to use sqlread with a sqlite connection, you will probably have to establish that connection using the jdbc driver, then you can use sqlread. See details (section on how to programatically do this in the middle of the article: SQLite JDBC for Windows - MATLAB & Simulink (mathworks.com)
Otherwise, just use fetch.

Walter Roberson
Walter Roberson 2022년 9월 30일
https://www.mathworks.com/help/database/ug/sqlite.sqlread.html
sqlread() for sqllite() requires r2022a or later; you are using r2021a.
  댓글 수: 1
Alex
Alex 2022년 9월 30일
I will install an upgraded version to test, but thank you. This is one of my biggest frustrations with the MATLAB documentaiton. I'm not sure what you searched/how you obtained different documentation for the same function, sqlread() when both pages state they are up-to-date for R2022b. This has been a reoccuring pain point for me, is there something I'm missing with respect to how to navigate MATLAB documentation. I've never experienced this issue with other programming languages or any major application (at least that I can recall) w.r.t. documention. Typically, if I search for something and look at an official documentation page for another language/application, if differences exist, it is obvious based on product/document version number. Sometimes the site gives a product version number to select (when version dependent documention is maintained) or there are explicit annotations for depreciated functionality or date implemented annotations for new functionality. However, in a case like this, I am not able to identify the relevance of two, extremely similar, independent pages. If you have some recommendations for navigating MATLAB documentation that would be extremely helpful.

댓글을 달려면 로그인하십시오.

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by