POS Pizza Database Query Tool
POS Pizza Database Query Tool
This is a command line tool which allows you to build queries in SQL to search the POS Pizza database
for specific data and output it to a CSV file. CSV files are a universal format which can be opened in
Excel or similar apps for further evaluation of the data. The basic schema of the POS Pizza database is
detailed at the end of this document.
Usage
The executable will be called with a single parameter passed to it on the command line. That parameter
is the file name which contains the parameters to be used during the call. Multiple parameters files can
be configured allowing you to call different queries and have them output to different files based on
timed events using the Windows scheduler or similar utility. An example call is shown below.
POSPZDBQT employeeIDs.txt
POSPZDBQT.exe is the application and employeeIDs.txt is the parameters file in the call above. The
contents of employeeIDs.txt might look something like what is below.
server=auto
database=pospizza.db3
csv=employeeids.csv
query=SELECT EmployeeNum, EmployeeID
FROM employees_tbl
ORDER BY _ROWID_;
The parameters file is a standard text file which can be created in Notepad.
Comments or notes can be added directly in the file without any special characters so long as they are
not on the same line as one of the four required parameters. To add a comment on the same line as a
parameter, the comment must be preceded by // two forward slashes as shown in the following
example.
This line of text is a comment and will be ignored by the query tool.
server=auto // auto-detect the database server.
Each parameters file requires four key parameters so that the query tool knows what to do. These
parameters are the following; server, database, csv, and query.
The server parameter can either be auto or the IP address or FQDN (Fully Qualified Domain Name) to a
POS Pizza database server. The parameter name must be followed immediately by the = sign followed
immediately by the parameter. If the server is remote to the location that you are running this tool
from, you will need to include the eKey= parameter, and include an eKey generated from the
management utility (run locally) from the location that you wish to connect to.
The database parameter is the full file name (no paths, filename only) of the POS Pizza database file
that you wish to work with. POS Pizza’s default file name is pospizza.db3, so this will likely be used most
of the time. The parameter name must be followed immediately by the = sign followed immediately by
the parameter.
The csv parameter is the name of the output CSV file to be used. This parameter can optionally include
a full path name if desired. If no path is used, then the CSV file will be created in the same folder as the
application. The parameter name must be followed immediately by the = sign followed immediately by
the parameter.
CSV file variables – You can optionally embed file name variables into the output CSV file name
to make it more unique. This is good if you are automating the call to the Query Tool and
generating reports nightly, monthly etc. This ensures that each file will have a unique name, so
as not to overwrite a previous period’s output data.
The above line would output a file named Daily_20210210.csv on Feb 10th 2021.
The query parameter is the SQL query to be used to create the CSV file’s output data. This can be on a
single line or on multiple lines. The query must always end with a semicolon ; at the end of it. The
parameter name must be followed immediately by the = sign followed immediately by the parameter. A
single line and multi-line example are shown below.
query=SELECT * FROM orders_tbl ORDER BY order_date DESC LIMIT 1;
Muti-line queries make longer more complicated SQL queries much easier to read. All comments within
a mutl-line query must be preceded by //.
Date variables can be embedded into the query instead of literal date/time values in order to customize
files that might be called routinely as part of an automated process. When doing so, you should also use
CSV file name variables along with it. The following date / date time variables are recognized by the
Query tool. NOTE: These are CASE SENSITIVE and must be embedded in the query exactly as shown.
• %ThisMonthStart% -- DateTime for the first day of the current month at midnight
• %ThisMonthEnd% -- DateTime for the last day of the current month at 11:59:59 pm
• %LastMonthStart% -- DateTime for the first day of the previous month at midnight
• %LastMonthEnd% -- DateTime for the last day of the previous month at 11:59:59 pm
• %LastWeekStart% -- DateTime for the Sunday of the previous week at midnight
• %LastWeekEnd% -- DateTime for the Saturday of the previous week at 11:59:59 pm
• %ThisWeekStart% -- DateTime for Sunday of the current week at midnight
• %ThisWeekEnd% -- DateTime for Saturday of the current week at 11:59:59 pm
• %YesterdayStart% -- DateTime for the previous day at midnight
• %YesterdayEnd% -- DateTime for the previous day at 11:59:59 pm
• %TodayStart% -- DateTime for the current day at midnight
• %TodayEnd% -- DateTime for the current day at 11:59:59 pm
• %Year% -- 4-digit current year (used for building custom date or datetime strings)
• %LastYear% -- 4-digit previous year (used for building custom date or datetime strings)
• %Month% -- 2-digit current month (used for building custom date or datetime strings)
• %LastMonth% -- 2-digit previous month (used for building custom date or datetime strings)
• %Day% -- 2-digit current day of month (used for building custom date or datetime strings)
query=SELECT * FROM customers_tbl WHERE last_login BETWEEN ‘%LastMonthStart%’
AND ‘%ThisMonthEnd%’;
The above values can be embedded into any date/time related searches and will turn into the actual
dates/times before used to query the database. Make sure to enclose the above variables inside of the
needed single ‘ quote marks as required by SQL for handling string values such as dates and times.
The Query tool creates a log file called POSPZDBQT_log.txt in the same folder as the .exe file. This file
will contain any errors that occur while trying to run the tool. If no errors occur, no entries will be
written to the log.
Several example .txt parameter files are included and are named POSPZDBQT_sample1.txt,
POSPZDBQT_sample2.txt, and POSPZDBQT_sample3.txt. Edit these in Notepad to see some examples of
the usage of the parameters file.
In order to effectively use this tool, knowledge of SQL and more specifically SQLite is needed in order to
generate effective queries. More information on SQLite can be found at: https://sqlite.org/index.html
Some tables in POS Pizza’s database contain uniquely encrypted data elements. The configuration table
main_cfgs_tbl and the employees table employees_tbl both contain encrypted data within the BLOB
type fields and are not readable as clear text.
POS Pizza’s database as of v9.00.00 is detailed in the POS Pizza Database Scheme PDF document.