>> Instead use operating system commands to retrieve the full path to the first >> file, then construct a full path to the second file. > > But if a I have an arbitrary SQL script/procedure to perform, that starts > with an attach statement, I don't have creation control over the path > specified in the script.
What's wrong with the following suggestion to you? >> Just start sqlite3 in such a way that the directory where your database >> files reside is the current one. You can read it as: change your app so that before executing the script it sets current directory to the one with the original database. > For the moment, I've actually had to use a regex to change the SQL script to > insert a path if it's missing, but that is unscrambling the egg and will only > help my app, not if the database files and script are opened in another app. If you want to execute such script with attach from different apps and those apps don't know about your attach command and can't set current directory accordingly that can only mean that you try to hack these apps and perform some illegal operation in them. Don't do that. Pavel On Thu, Feb 3, 2011 at 9:59 AM, BareFeetWare <list....@barefeetware.com> wrote: >>> On 3 Feb 2011, at 1:03am, BareFeetWare wrote: >>> >>> How can I attach to a local file in the same directory, without specifying >>> the full absolute path? > >> On 03/02/2011, at 12:17 PM, Simon Slavin wrote: >> >> No easy way. > > Argh. That's kind of mental, that SQLite, a file based database system, can't > in SQL either tell you the path to the main database (eg via a function) or > let you open a secondary file in the same directory. > >> Instead use operating system commands to retrieve the full path to the first >> file, then construct a full path to the second file. > > But if a I have an arbitrary SQL script/procedure to perform, that starts > with an attach statement, I don't have creation control over the path > specified in the script. > > For the moment, I've actually had to use a regex to change the SQL script to > insert a path if it's missing, but that is unscrambling the egg and will only > help my app, not if the database files and script are opened in another app. > > I am replacing occurrences of: > attach\s+'([^/].*?)' > with: > attach '<directoryPath>/$1' > > Thanks, > Tom > BareFeetWare > > -- > Comparison of SQLite GUI tools: > http://www.barefeetware.com/sqlite/compare/?ml > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users