Re: [sqlite] Stream loading SQL script

2019-10-27 Thread x
Thanks Keith. I thought it was a documented function and couldn’t find anything 
in the documentation.








From: sqlite-users  on behalf of 
Keith Medcalf 
Sent: Sunday, October 27, 2019 4:46:17 PM
To: SQLite mailing list 
Subject: Re: [sqlite] Stream loading SQL script


On Sunday, 27 October, 2019 07:40, x  wrote:

>Where is this function Keith? I can find any information on it?

The SQLite3 command line shell (shell.c) reads input from stdin or other file 
and processes the commands one at a time by either calling the appropriate 
sqlite3 functions and displaying the output, or handling them internally.  
process_input is the function within the shell.c code which reads the input and 
decides when sufficient input has been collected to constitute a complete 
command for processing.  It is internal to shell.c and not part of any external 
documented API so the only documentation is to read the code.  If you want to 
know how the command line shell converts between a stream of input characters 
and recognizes when a complete command line has accumulated, this is the 
internal function that does that.

>
>From: sqlite-users  on
>behalf of František Kučera 
>Sent: Saturday, October 26, 2019 4:49:26 PM
>To: sqlite-users@mailinglists.sqlite.org us...@mailinglists.sqlite.org>
>Subject: Re: [sqlite] Stream loading SQL script
>
>Dne 25. 10. 19 v 21:41 Keith Medcalf napsal(a):
>> The sqlite3 command line shell already does this.  see function
>process_input
>
>Thanks, it helped.
>
>I see that it checks whether the input contains a semicolon and only
>then it calls sqlite3_complete(). So I implemented it in a similar way
>in C++.
>
>Franta

--
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.



___
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


Re: [sqlite] Stream loading SQL script

2019-10-27 Thread Keith Medcalf

On Sunday, 27 October, 2019 07:40, x  wrote:

>Where is this function Keith? I can find any information on it?

The SQLite3 command line shell (shell.c) reads input from stdin or other file 
and processes the commands one at a time by either calling the appropriate 
sqlite3 functions and displaying the output, or handling them internally.  
process_input is the function within the shell.c code which reads the input and 
decides when sufficient input has been collected to constitute a complete 
command for processing.  It is internal to shell.c and not part of any external 
documented API so the only documentation is to read the code.  If you want to 
know how the command line shell converts between a stream of input characters 
and recognizes when a complete command line has accumulated, this is the 
internal function that does that.

>
>From: sqlite-users  on
>behalf of František Kučera 
>Sent: Saturday, October 26, 2019 4:49:26 PM
>To: sqlite-users@mailinglists.sqlite.org us...@mailinglists.sqlite.org>
>Subject: Re: [sqlite] Stream loading SQL script
>
>Dne 25. 10. 19 v 21:41 Keith Medcalf napsal(a):
>> The sqlite3 command line shell already does this.  see function
>process_input
>
>Thanks, it helped.
>
>I see that it checks whether the input contains a semicolon and only
>then it calls sqlite3_complete(). So I implemented it in a similar way
>in C++.
>
>Franta

-- 
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume. 



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Stream loading SQL script

2019-10-27 Thread x
Where is this function Keith? I can find any information on it?








From: sqlite-users  on behalf of 
František Kučera 
Sent: Saturday, October 26, 2019 4:49:26 PM
To: sqlite-users@mailinglists.sqlite.org 
Subject: Re: [sqlite] Stream loading SQL script

Dne 25. 10. 19 v 21:41 Keith Medcalf napsal(a):
> The sqlite3 command line shell already does this.  see function process_input

Thanks, it helped.

I see that it checks whether the input contains a semicolon and only
then it calls sqlite3_complete(). So I implemented it in a similar way
in C++.

Franta


___
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


Re: [sqlite] Stream loading SQL script

2019-10-26 Thread František Kučera
Dne 25. 10. 19 v 21:41 Keith Medcalf napsal(a):
> The sqlite3 command line shell already does this.  see function process_input

Thanks, it helped.

I see that it checks whether the input contains a semicolon and only
then it calls sqlite3_complete(). So I implemented it in a similar way
in C++.

Franta


___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Stream loading SQL script

2019-10-25 Thread Keith Medcalf

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  On
>Behalf Of František Kucera
>Sent: Friday, 25 October, 2019 13:16
>To: SQLite mailing list 
>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:
> sources:
>
>
>
>___
>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