On 31 Aug 2011, at 2:53am, Pete Helgren wrote: > Thanks. I'll add a little more info.... > > This script is used to set up the initial DB in a programmable device that > will then record data to the database and the database should never be > replaced. So I just figured there would be a simple way to issue the sqlite > commands in script.
The mechanism in SQLite which creates a database is to open one that doesn't exist. There's no command or C function which just makes a database without opening it. You could, of course, hack that functionality out of the source code but I think that's a poor solution. > Even found an example using a createdb command, although I could never see > where that was an SQLite command.... > > So, you suggest I script it like so: > > if [ -f /data/newdatabase.db]; > then > echo "Nothing to do, database exists" > else > cp newdatabase.db /data/newdatabase.db > fi > > I am not much of a Linux guy so the scripting might be wrong..... That would do fine. But as a single-command alternative you could use 'cp -n': cp -n newdatabase.db /data/newdatabase.db the '-n' means 'don't replace an existing file'. I tested it on my Unix box. I believe it's implemented in Linux, but you should definitely test it because I don't have Linux here. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users