Adelphia web hosting

152 Part II . SQL Essentials Using the CLI in Non-Interactive Mode The CLI need not be used interactively; sometimes running a simple query or command on the server does the job. For example, you may want to redirect the output of a statement to a file, or use a scheduler (such as cron) to schedule the running of a particular command. In such instances, the MySQL CLI can be used in a non- interactive mode that makes it operate like any basic, straightforward command. Executing a statement When you re operating in non-interactive mode, one of the most frequent and useful operations is to execute a statement. To do so, you use the -e or –execute= command-line switch. For example, to run a simple query that finds the users and hosts allowed to connect to a particular database, you can use the -eswitch as illustrated in Figure 8-26. Figure 8-26: Using the -e switch to run a simple query In Figure 8-26, I specified the -pswitch to have MySQL prompt for the password. Next comes the -e switch, followed by the statement to execute in quotes. Finally comes the name of the database to connect to (in this case, mysql, because that s where user data is stored). Printing HTML output One especially handy feature of the MySQL CLI is that it can output a query in HTML format a capability you can use to create a simple Web page from a query without much effort. The switch that produces HTML output is -H or –html. For example, suppose I want to make a Web page consisting of a simple report of the products in the ecommercedatabase example (yes, all three of them.) In Figure 8-27, I ran the command to produce the output.
Note: In case you are looking for affordable webhost to host and run your web application check Vision cheap hosting services

Leave a Reply