> From: Bill Harris > > I've got a process that starts with a J script to pull many > spreadsheets > into one csv file and then uses a file of sql commands that sqlite3 > executes in cygwin bash to populate a database. I'd like to run > everything from J and, in the process, lose the dependency on cygwin. > > I'm stuck on running the sql to populate the database. It contains a > few > dot commands for sqlite3, and exec__db seems to choke on those.
>From the sqlite documentation it sounds as though the dot commands (eg. >.tables) are just convenience functions that create SQL. From: http://sqlite.org/sqlite.html <quote> The ".tables" command is similar to setting list mode then executing the following query: SELECT name FROM sqlite_master WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' UNION ALL SELECT name FROM sqlite_temp_master WHERE type IN ('table','view') ORDER BY 1 In fact, if you look at the source code to the sqlite3 program (found in the source tree in the file src/shell.c) you'll find exactly the above query. </quote> Might be worthwhile looking up the C source for ".import" and working out what SQL it is creating. > The commands I'm using are > > .database cpredik.sqlite > .separator "|" > .import Predik.csv predik > .exit > > The first and last are a bit superfluous in the J context, but they are > there to keep sqlite3 happy when run from the shell. The middle two > could > probably be replaced with a bulkins, but then that wouldn't be > compatible > with sqlite3. > > Is there a way to have this one .sql file that will run both with > sqlite3 > from the shell (bash) and inside J using exec__db? > > Thanks, > > Bill > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
