What is macOS sqlite3 db file relative path lazarus / 16-Databases ---------------------------------------------------------------------- shenzhu · 2025-01-08 04:20 I tested that both Windows and Ubuntu can connect SQLite3 files with relative paths, such as test.db I am experimenting with macOS using the relative path test.db or ./test.db all failed to connect But absolute paths such as/Users/dyname/razcode/z2/test.db can be used to connect How can I use relative paths to connect SQLite3 files in macOS? If the relative path is possible, in which directory should the sqlite3 data file be placed again? ---------------------------------------------------------------------- Zvoni · 2025-01-08 07:38 Quote from: shenzhu on January 08, 2025, 05:20:40 amI tested that both Windows and Ubuntu can connect SQLite3 files with relative paths, such as test.db I am experimenting with macOS using the relative path test.db or ./test.db all failed to connect But absolute paths such as/Users/dyname/razcode/z2/test.db can be used to connect How can I use relative paths to connect SQLite3 files in macOS? If the relative path is possible, in which directory should the sqlite3 data file be placed again? If with "relative" path you mean relative to your executable, i think i remember something that an AppBundle can have/has its own Support Folders/Containers beneath it. No Mac-Expert here, though. Maybe wait for someone more knowledgable ---------------------------------------------------------------------- shenzhu · 2025-01-08 12:58 Thank you for your reply. For more information about this issue, please refer to this wiki https://wiki.lazarus.freepascal.org/SQLite#Using_the_SQLdb_components_ with_SQLite QuoteDatabaseName: Set this property to the file name (absolute path!) of your SQLite file. Unfortunately, you cannot simply use a relative path that works unchanged at designtime and at runtime ***is this still true? Can't you just copy the db file in a post-build shell script or symlink it?***. You should make sure that at application start the correct path to the file is always set programmatically, no matter what it contained at designtime. Unfortunately, the statement on the wiki is incorrect. for designtime, Windows and Linux can use relative paths, and many articles online also introduce absolute paths. Such programs cannot be published. This problem should be a broad one that even experienced programmers find difficult to solve. Looking forward to tips from programmers with experience in macOS development. How is SQLite3 connected in XCODE? ---------------------------------------------------------------------- Zvoni · 2025-01-08 13:06 Quote from: shenzhu on January 08, 2025, 01:58:25 pmThank you for your reply. For more information about this issue, please refer to this wiki https://wiki.lazarus.freepascal.org/SQLite#Using_the_SQLdb_components_ with_SQLite QuoteDatabaseName: Set this property to the file name (absolute path!) of your SQLite file. Unfortunately, you cannot simply use a relative path that works unchanged at designtime and at runtime ***is this still true? Can't you just copy the db file in a post-build shell script or symlink it?***. You should make sure that at application start the correct path to the file is always set programmatically, no matter what it contained at designtime. Unfortunately, the statement on the wiki is incorrect. for designtime, Windows and Linux can use relative paths, and many articles online also introduce absolute paths. Such programs cannot be published. This problem should be a broad one that even experienced programmers find difficult to solve. Looking forward to tips from programmers with experience in macOS development. How is SQLite3 connected in XCODE? Wrong. It's still an absolute path, you just don't see it in those blasted "visual" components. The important sentence is this: QuoteYou should make sure that at application start the correct path to the file is always set programmatically, no matter what it contained at designtime.