The sqlite3 command line shell already does this. see function process_input
-- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> On >Behalf Of František Kucera >Sent: Friday, 25 October, 2019 13:16 >To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> >Subject: [sqlite] Stream loading SQL script > >Hello, > >I am developing a tool* in C++ and one of its features will be that it >will load an SQL script (CREATE TABLE, INSERT), execute it, then execute >some queries and print results. > >The SQL script might be long and I do not want to load it whole in the >memory. Usually it will easily fit, but the tool should be capable to >process longer scripts with constant memory usage. What is recommended >way? > >I see that there is sqlite3_complete() function, which can detect >complete query, but I would have to check the input using this function >character by character, to stop exactly at the semicolon and then >execute. > >Or I can try to execute what I have loaded and if it fails, load more – >but this way I risk that I load incomplete statement, which could be >valid and mistakenly executed (e.g. DELETE or SELECT without WHERE >condition). So this will also not work. > >Franta > >*) if anyone interested, it is free software, described here: ><https://relational-pipes.globalcode.info/> sources: ><https://hg.globalcode.info/relpipe/relpipe-tr-sql.cpp/> > > >_______________________________________________ >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