On 16 January 2016 at 07:16, Roger Binns <rogerb at rogerbinns.com> wrote:

>
> > while p.poll() == None: resp = p.communicate() print len(resp[0]),
> > resp[0]
>
> That code doesn't make sense.  communicate waits until the process
> terminates.  The SQLite shell won't terminate unless it gets a quit
> command, or EOF on stdin.
>

Yeah in hindsight it wasn't the best. I was trying to do:

while still running:
    p.communicate etc

Poll is not the right method to call.


> > The problem I'm trying to solve is: When my application that uses
> > an sqlite3 database gets the "database disk image is malformed" I
> > need to be able to give the user a "repair" option which dumps the
> > datrabase to an .sql file and reimport it all. I'm assuming the
> > best way is to do that via the shell rather than try and copy all
> > the dump code into my own application.
>
> Good news - here is a shell in Python I already made for you:
>
>   https://rogerbinns.github.io/apsw/shell.html#shell-class
>   https://github.com/rogerbinns/apsw/blob/master/tools/shell.py


Well if I get stuck then I'll have a look at that. But after I sent that
message I had a closer look at the available arguments to sqlite3.exe and
one of them stood out:

    -interactive

Once I passed that to the command line as well as the database path it
started working like a normal process with the stdin and stdout pipes. So I
have what I need in terms of being able to control the sqlite3.exe from my
application.

Regards
Matt

Reply via email to