フィルターのクリア

Error importing sqlite database from autogenerated script

1 回表示 (過去 30 日間)
Gur Sevak Singh
Gur Sevak Singh 2021 年 2 月 19 日
回答済み: Sai Sumanth Korthiwada 2022 年 12 月 20 日
Hi,
i'm a little new to matlab and am having a bit of trouble with the database explorer.
i cant seem to run the import data auto-generated script without an error coming up even if it's so simple. connection works and i can even import the data manually through the UI. but each time i try the generated script, this happens:
Script:
% Auto-generated by MATLAB Version 9.8 (R2020a) and Database Toolbox Version 9.2.1 on 19-Feb-2021 10:24:44
%% Make connection to database
conn = database('articaresLite_v2','','');
%Set query to execute on the database
query = ['SELECT * ' ...
'FROM UserExtendedModel'];
%% Execute query and fetch results
data = fetch(conn,query);
%% Close connection to database
close(conn)
%% Clear variables
clear conn query
>>UserExtMdl %this is the script's name
Error using UserExtMdl (line 17)
JDBC Driver Error: Error parsing date
Does anyone know what to do to get it working via script?
  1 件のコメント
Gur Sevak Singh
Gur Sevak Singh 2021 年 2 月 19 日
P.S. i've tried new drivers as well as older ones, and the same error comes up.

サインインしてコメントする。

回答 (1 件)

Sai Sumanth Korthiwada
Sai Sumanth Korthiwada 2022 年 12 月 20 日
Hi Gur Sevak,
There are two workarounds for this issue.
1. Using the ‘select’ Function
You can use the same connection, but alter your code to use the "select" function which will fetch the results from the database connection. The code should look like this:
>> conn = database(...);
>> selectquery = 'select * from myTable';
>> results = select(conn, selectquery);
>> close(conn);
Refer to the following documentation link for more information about "select" function: https://in.mathworks.com/help/releases/R2020a/database/ug/select.html
2. Using the ‘fetch’ Function
You can also use the "fetch" function which will fetch the results from the database connection. The code should look like this:
>> conn = database(...);
>> sqlquery = 'select * from myTable';
>> results = fetch(conn, sqlquery);
>> close(conn);
Refer to the following documentation link for more information about "fetch" function: https://in.mathworks.com/help/releases/R2020a/database/ug/database.odbc.connection.fetch.html
Hope this resolves your issue.

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by