Shane. Expect to do a lot of hacking on shell.c. It's not intended as a library but as the main program of a console application. Another way involves controlling the IO handles of your process and sending strings but that will probably run into portability problems that are even a bigger headache.
Proceeding from the assumption the main program will be in a different compilation unit, that function you want to call will have to be exportable instead of static and you'll have to get a valid ShellState from somewhere. You could start your hacking by adding an exportable function that takes only zLine and a forged ShellState to pass into the ultimate do_meta_command() call. Shell.c is interactive so you have to watch out for it messing around with your program's IO handles. If you plan to use other shell.c functions and/or keep up with changes/fixes to the original shell.c, try to isolate your changes to just the exported functions you add and figure out some minimal #ifdef changes to disable the IO interactions. There is no guarantee your additions and #ifdefs will continue to work if shell.c has changes/fixes. Expect merge headaches every time there's a new release you want for your product. If you only need the .import function, cloning that code into your program could be easier to maintain but probably more work up front. Peter On Tue, Jan 16, 2018 at 10:13 PM, Shane Dev <devshan...@gmail.com> wrote: > Apparently the CSV virtual table supports neither changes (INSERT, UPDATE, > DELETE), nor reading single column csv files. > > What I really want is the functionality of .import and .output SQLite shell > commands. Maybe a better strategy would be to compile shell.c with my c > program and call the function do_meta_command(char *zLine, ShellState *p). > > To those familiar with shell.c, is this a reasonable approach? > > On 17 January 2018 at 00:15, Richard Hipp <d...@sqlite.org> wrote: > > > On 1/16/18, Shane Dev <devshan...@gmail.com> wrote: > > > I tried - > > > > > > sqlite> CREATE VIRTUAL TABLE temp.t1 USING csv(filename='test.tsv'); > > > > > > where test.tsv is a tab separated table. However > > > > > > select count(*) from t1; > > > > > > goes into an infinite loop. Do you how to specify a separator other > than > > > ","? > > > > The "C" in CSV stands for "Comma". That is the only separator > > supported. But, you can probably edit the source code to do something > > different. > > > > -- > > D. Richard Hipp > > d...@sqlite.org > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@mailinglists.sqlite.org > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users