Client 5—An Interactive Query Program

Let's put together much of what we've developed so far and use it to write a simple interactive client. It lets you enter queries, executes them using our general purpose query handler process_query(), and displays the results using the process_result_set() display formatter developed in the preceding section.

client5 will be similar in some ways to mysql, although of course not with as many features. There are several restrictions on what client5 will allow as input:

  • Each input line must contain a single complete query.

  • Queries should not be terminated by a semicolon or by '\g'.

  • Commands such as quit are not recognized; instead, use Control-D to terminate the program.

It turns out that client5 is almost ...

Get MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.