Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The command line shell does not quit where the SQLite tool does. #115

Closed
rogerbinns opened this issue Dec 29, 2013 · 5 comments
Closed

The command line shell does not quit where the SQLite tool does. #115

rogerbinns opened this issue Dec 29, 2013 · 5 comments

Comments

@rogerbinns
Copy link
Owner

From pasma10@concepts.nl on April 09, 2011 13:33:51

What steps will reproduce the problem? 1.python -c "import apsw;apsw.main()" "select 123" 2. 3. What is the expected output? What do you see instead? After the output from the query I'd expect to return to the system prompt or whatever started the APSW shell. But the programme prompt for the command. What version of the product are you using? On what operating system? 3.7.5- r1 Please provide any additional information below.

Original issue: http://code.google.com/p/apsw/issues/detail?id=115

@rogerbinns
Copy link
Owner Author

From rogerbinns on April 09, 2011 14:04:30

You've started an interactive shell on a database named "select 123" :-)

In any event supplying a database does still result in prompt. There was a deliberate design behind this. The APSW shell lets you supply multiple SQL strings on the command line whereas the SQLite shell doesn't:

$ python shell.py :memory: "select 123" "select 456" ".quit"
123
456
$

$ sqlite3 :memory: "select 123" "select 456" ".quit"
sqlite3: Error: too many options: "select 456"
Use -help for a list of options.
$

There are several ways of making sure the APSW shell doesn't prompt for input. Use .quit on the commandline or provide /dev/null as standard input. The latter also works with SQLite's shell. I like the dev null approach as it makes things very clear.

I'm not really sure what to do as APSW's shell is so much more functional. I think current behaviour is the least worst default but am willing to be persuaded otherwise.

Status: Accepted

@rogerbinns
Copy link
Owner Author

From pasma10@concepts.nl on April 11, 2011 05:11:03

There is so much useful functions that I hardly dare to critizize. For instance the feature to pass multiple SQL arguments is so powerful because it actually passes mulitple [SQL or COMMAND] arguments. Multiple SQL is already possible in SQLite (seperated by ; in a single argument).

Another point, which may need to become another issue, is that the shell does not understand a command like '.q' and expects the full '.quit'. Of course APSw's tabcompletion makes this easy. But it is special if one is used to SQLite.

@rogerbinns
Copy link
Owner Author

From rogerbinns on April 11, 2011 07:36:04

I don't consider "criticism" a bad thing. The underlying goal is to make APSW better so any discussion with that in mind is always good. The only problem I have with the SQLite shell default behaviour is that there is no way to provide SQL/commands via the command line and be interactive. Throwing extra flags at the problem could help but in this case I think the APSW shell is being a little more useful by default.

On the command abbreviations side I'd never seen anyone use abbreviations. It is a few lines of extra code to implement them. My concern is that as APSW shell gets extra commands (see issue 113 ) commands could become ambiguous. For example if .quota is added then suddenly .q won't work for quit any more. Also being a Python person I'm all in favour of explicit rather than implicit :-)

@rogerbinns
Copy link
Owner Author

From pasma10@concepts.nl on April 11, 2011 11:16:28

The behaviour of the SQLite shell makes sense because one would normally not pass SQL on the command line if one intends interactive use. The SQLite document http://www.sqlite.org/sqlite.html describes the option in the paragraph "Using SQLite3 in a shell script". It sais the mechanism is designed to make sqlite3 easy to use in combination with programs like "awk". (or "sed" if you like). It has an example where the ouput is send to a pipe that will probably hang in the apsw shell. It would be convenient from a documentation point of view if all sqlite examples work, so you can just refer to them. Possibly I have been mislead by http://apidoc.apsw.googlecode.com/hg/shell.html that mentions something like this.

Another argument: the sqlite behaviour is in line with the Python interpretor (need an explicit -i to become interactive in this case).

Criticism enough.

Edzard Pasma

@rogerbinns
Copy link
Owner Author

From rogerbinns on May 05, 2011 13:31:37

Fix in rab44e5c082cf

Status: Verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant