Borrar filtros
Borrar filtros

Error importing sqlite database from autogenerated script

1 visualización (últimos 30 días)
Gur Sevak Singh
Gur Sevak Singh el 19 de Feb. de 2021
Respondida: Sai Sumanth Korthiwada el 20 de Dic. de 2022
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 comentario
Gur Sevak Singh
Gur Sevak Singh el 19 de Feb. de 2021
P.S. i've tried new drivers as well as older ones, and the same error comes up.

Iniciar sesión para comentar.

Respuestas (1)

Sai Sumanth Korthiwada
Sai Sumanth Korthiwada el 20 de Dic. de 2022
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.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by