On Tue, Aug 30, 2011 at 08:29:06PM -0600, Pete Helgren scratched on the wall: > The only issue I had was finding an example of how I could do all of > what you describe below in bash script. For example, if I put this > in a script: > > sqlite3 newdatabase.db > > and save that as createdb.sh and execute it then the script never > completes because SQLite is at the sqlite> prompt, waiting for > commands. Hence that option is a non-starter.
You need to give sqlite3 a command, or it will go into interactive mode. That's how the shell is designed to work. You can do this, however: $ sqlite3 newdatabase.db .exit The existence of the command will cause sqlite3 to execute the command and quit, without going into interactive mode. As I explained before, this specific example won't actually create a database file, however. I suppose you could do something this: sqlite3 newdatabase.db "CREATE TABLE IF NOT EXISTS ..." sqlite3 newdatabase.db "CREATE TABLE IF NOT EXISTS ..." ... But that seems a bit wasteful. If you want to do all your initialization in one pass, I would do something like this: sqlite3 newdatabase.db << EOF CREATE TABLE IF NOT EXISTS t1 ( a, b, c ); CREATE TABLE IF NOT EXISTS t2 ( d, e, f ); EOF -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users