sqlite ignore project path?

2 次查看(过去 30 天)
Simon
Simon 2024-5-14
评论: Simon 2024-5-21
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")

采纳的回答

Saurabh
Saurabh 2024-5-21
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by