Clear Filters
Clear Filters

sqlite ignore project path?

3 views (last 30 days)
Simon
Simon on 14 May 2024
Commented: Simon on 21 May 2024
I have a sqlite database, say "filename.db", in a local folder (MacOS). The folder is then added to my project path. However, sqlite can find it with absolute path, but not with filename. Can sqlite not search in the project path?
% works
conn = sqlite(full_absolute_path/"filename.db", "connect")
% Error: database not found
conn = sqlite("filename.db", "connect")

Accepted Answer

Saurabh
Saurabh on 21 May 2024
Hi Simon,
I understand that you have added your folder to the MATLAB path and want to know if 'SQLite’ function can search on the project path or not.
'SQLite' does not automatically search within project or MATLAB’s path for database files. Instead, it relies on either an absolute path or a path relative to the current working directory (Where the MATLAB session or script is running from) to locate the database file.
When just provided with filename like ‘filename.db’, 'SQLite' function interprets it as being in the current working directory. If the file is not in the current working directory, an error will be encountered stating that database is not found. To address this issue, either use an absolute path:
conn = sqlite("/full/absolute/path/filename.db", "connect");
or use a relative path that is if the database file is in a known location relative to the current working directory from which your MATLAB code is being executed:
conn = sqlite("./relative/path/to/filename.db", "connect");
For More information on SQLite function leverage the link below:
I hope this was helpful.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!