Creating a Report through Command Line

You can automate report creation process using command line. Such possibility can be very useful if you need to create a report using the same report file. For this, you will need to create a report template to use it afterwards in the command line. Note that some parameters can be specified directly in the command line. In this case values of these parameters specified in your template file will be overridden.

The walkthrough described further in this topic will show you how to use command line in order to automate the following data report routines: saving a report on disk in the HTML format, sending it by email and FTP.

Creating a Report Template

To create a report template, you should perform the following actions:

  1. Click Design New Report on the Data Analysis tab of the product Start page. The Data Report Wizard opens.
  2. Follow the wizard pages to create a report template file with .rdb extension.
  3. Compose the report template.
  4. Save the file for future usage.

Prerequisites

To complete the following walkthrough, you need to have an already created report file with *.rdb extension. Refer to the corresponding tutorials to create and master-detail report files that can be used in command line as input files.

In this walkthrough Report1.rdb file, created in the Creating a Simple Data-Aware Report will be used.

Working with Data Reports

Suppose you need to send a data report containing customers’ address and phone number list in HTML format to your authorities via e-mail and FTP every day. For this, you have a report template Report1.rdb (the file is located in C:\dbForge Studio\Reports), the folder on disk to which the report should be saved is C:\dbForge Studio for MySQL\Reports\Output\, the e-mail address of your authorities is [email protected], the address of your FTP server is ftp://myftphost.net/reports/, login is send-report, and password is report.

To accomplish such task through command line, you need to perform the following steps:

  1. Open Command Prompt by pressing Win+R and type cmd in the Open line.

    Note

    To run Command Line in Windows 8:

    From the Desktop Mode

    • Move the mouse cursor to the exact lower left corner until the desktop shortcuts menu appears
    • Right-click to see the shortcut menu and then click Run

    From the Charms Bar

    • Move your mouse to the upper right corner until the Charms Bar appears
    • Select Apps from the list and type run in the search box
    • Click Run from the search results

    Use Windows + R Shortcut Keys

    In the desktop mode, press Windows key + R to show the Run command line.

  2. Change the path available in your Command Prompt window to the path where the dbforgemysql.com file is located (by default it’s C:\Program Files\Devart\dbForge Studio for MySQL). For this, use the cd operator:

     C:\Users\User>cd C:\Program Files\Devart\dbForge Studio for MySQL\
    

    Press Enter. You can see that the path has changed:

     C:\Program Files\Devart\dbForge Studio for MySQL>
    
  3. Now, call the dbforgemysql.com file:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com

  4. Specify the /datareport operation switch:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport

  5. Specify the path to your Report1.rdb input file and the name of the file itself:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport /reportfile:”C:\dbForge Studio for MySQL\Reports\Report1.rdb”

  6. Specify the format you want to save your report in. In this case, it’s HTML:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport /reportfile:”C:\dbForge Studio for MySQL\Reports\Report1.rdb” /format:HTML

  7. (Optional) To include parameters declared in a query script to command line, you can use the /parameters operation. For example, the following query script:

     SELECT
     first_name, 
     last_name,
     email
     FROM customer
     WHERE store_id = :store_id and active = :active
    

    will look as follows:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport /reportfile:”D:\Projects\Report1.rdb” /parameters store_id:2 active:0

  8. To start working with the result file, type the /result operation.

    • To save your report in the specified folder on disk, type the path to this folder:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport /reportfile:”C:\dbForge Studio for MySQL\Reports\Report1.rdb” /format:HTML /result folder:”C:\dbForge Studio\Reports\Output"

    • To send your report by email, add the email address:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport /reportfile:”C:\dbForge Studio for MySQL\Reports\Report1.rdb” /format:HTML /result email:”[email protected]

    • To send your report to multiple emails, add the email addresses as follows:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport /reportfile:”C:\dbForge Studio for MySQL\Reports\DataReport1.rdb” /format:HTML /result email:”[email protected], [email protected]

    • To send your report by FTP, specify the host, login, and password:

    C:\Program Files\Devart\dbForge Studio for MySQL> dbforgemysql.com /datareport /reportfile:”C:\dbForge Studio for MySQL\Reports\Report1.rdb” /format:HTML /result folder:”ftp://myftphost.net/reports/ “ ftplogin:send-report ftppassword:report

Note

If your report is in HTML format and consists of several files or folders, it is not possible to send such report by email or FTP using command line interface.

Note

You can perform two actions at a time with the result: save it on disk and send by e-mail, or send it by FTP and e-mail.

Note

If you need to create the same report and perform the same action with the result frequently, you can save the needed command line in a *.bat file and run it each time you need to create a report. In this case you will not have to type all necessary operators manually in Command Prompt any more.

Note

To see quick help on the arguments available in the command line, you can type /datareport /?