Using SQLite3 with Cygwin

11,626

Solution 1

Interactive non-Cygwin program often don't work correctly in Cygwin terminals such as mintty that are based on pseudo terminal ("pty") devices. That's because Cygwin uses Windows pipes to emulate ptys, so native console program see a pipe where they expect to see a console. Among other issues, that often causes them to enter non-interactive mode. See here for lots more on this:

http://code.google.com/p/mintty/issues/detail?id=56

You might be able to get it to work tolerably using the -interactive switch, but the real solution is to install the Cygwin version of sqlite3 through Cygwin setup.exe.

Solution 2

Start Cygwin with command

C:\cygwin\Cygwin.bat

instead of

C:\cygwin\bin\mintty.exe
Share:
11,626

Related videos on Youtube

jmq
Author by

jmq

Updated on September 17, 2022

Comments

  • jmq
    jmq almost 2 years

    I'm trying to use sqlite3.exe command shell with a mintty terminal in cygwin. I tried the program from a windows command prompt and it works. When I try to use it from the cygwin mintty terminal it seems like the program hangs. I can see the parameters and the version. It's as if it stops writing to the terminal when I run the shell.

    Has anyone else had this issue before and if so how did you fix it? TIA.

    ~>sqlite3 -help
    Usage: C:\Windows\sqlite3.exe [OPTIONS] FILENAME [SQL]
    FILENAME is the name of an SQLite database. A new database is created
    if the file does not previously exist.
    OPTIONS include:
       -init filename       read/process named file
       -echo                print commands before execution
       -[no]header          turn headers on or off
       -bail                stop after hitting an error
       -interactive         force interactive I/O
       -batch               force batch I/O
       -column              set output mode to 'column'
       -csv                 set output mode to 'csv'
       -html                set output mode to HTML
       -line                set output mode to 'line'
       -list                set output mode to 'list'
       -separator 'x'       set output field separator (|)
       -nullvalue 'text'    set text string for NULL values
       -version             show SQLite version
    ~>sqlite3
    

    This is where it hangs. Below are the versions of some of the relevant software.

    ~>uname -srv
    CYGWIN_NT-6.1-WOW64 1.7.7(0.230/5/3) 2010-08-31 09:58
    ~>mintty --version
    
    mintty 0.9.5
    (C) 2010 Andy Koppe
    
    ~>bash -version
    bash -version
    GNU bash, version 4.1.9(3)-release (i686-pc-cygwin)
    Copyright (C) 2009 Free Software Foundation, Inc.
    

    EDIT: When I run the program from the windows command line the program works. This is what I should see:

    C:\Users\jmquigley\workspace\apis.net\sqlite>sqlite3
    SQLite version 3.7.5
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> .quit
    

    When I run the command in cygwin it never enters the shell; it appears to hang up and I have to CTRL + C to kill it and return back to the bash command prompt.

  • jmq
    jmq over 13 years
    I type "sqlite3" at the cygwin bash command prompt and the program just hangs. I have to use CTRL + C to exit and return back to the command prompt. When it starts "running" nothing happens.
  • jmq
    jmq over 13 years
    I was able to get it working by downloading the native build version through cygwin (your second option). I didn't even think about that option, heh. Thanks for the great explanation of why it doesn't work. I did try the first also, and it kind of worked (like you mentioned). There seemed to be a "buffer" delay where it would dump info in screens after you passed some threshold of characters. Thanks again.
  • eylon shabtay
    eylon shabtay over 13 years
    You're welcome. That output delay indeed is due to buffering: by default, output streams are unbuffered when connected to a console, but fully buffered when connected to a pipe.
  • ranjeet
    ranjeet about 7 years
    I don't think this is correct. Using one or another way to start cygwin will not affect how the program interacts with input/output, which is the root case here as explained by ak2 above.
  • Bowi
    Bowi over 6 years
    For me it solved the problem, so it at least could be correct. ;-)