Using SQLite3 with Cygwin

bashcygwin;minttysqlite

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.

Best Answer

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.

Related Question