7

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.

4 Answers 4

10

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.

2
  • 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.
    – jmq
    Mar 4, 2011 at 5:00
  • 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.
    – ak2
    Mar 4, 2011 at 12:45
2

Start Cygwin with command

C:\cygwin\Cygwin.bat

instead of

C:\cygwin\bin\mintty.exe
2
  • 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. Jun 5, 2017 at 18:16
  • For me it solved the problem, so it at least could be correct. ;-)
    – Bowi
    Feb 19, 2018 at 10:28
0

Not sure I'm understanding.

 ~>sqlite3

It "hangs" after the second ~>sqlite3 ?

At that point, you are no longer running sqlite3 are you? It has returned to a prompt. Initially all you did was to display it's help, & the program exited. Either type sqlite3.exe, alone, or provide a db to open, like sqlite3.exe places.sqlite. Then the program will remain open awaiting your commands.

(I have no knowledge of cygwin or mintty so that may be throwing me off?)

1
  • 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
    Mar 4, 2011 at 4:33
0

Unless you specifically need SQLite to work in Cygwin, the SQLite ODBC driver for windows may be a better option. It allows Windows-native access to SQLite databases through ODBC so that programs like OpenOffice Base and Microsoft Access, as well as many others can connect and use them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .