% This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
% Example 70 Creating a New Database with a Label
% Label: "ex:newdb"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{datatool}
% custom expandable command:
\newcommand{\limiteded}{limited edition}
% define data
 \DTLnewdb{mydata}
\DTLnewrow{mydata}% create a new row
% Add entries to the first row:
\DTLnewdbentry
 {mydata}% database label
 {Product}% column key
 {The Adventures of Duck and Goose}% value
\DTLnewdbentry
 {mydata}% database label
 {Quantity}% column key
 {1,452}% value
\DTLnewdbentry
 {mydata}% database label
 {Price}% column key
 {\$1.99}% value
\DTLnewrow{mydata}% create a new row
% Add entries to the second row:
\DTLnewdbentry
 {mydata}% database label
 {Product}% column key
 {Duck and Goose on Holiday}% value
\DTLnewdbentry
 {mydata}% database label
 {Quantity}% column key
 {94}% value
\DTLnewdbentry
 {mydata}% database label
 {Price}% column key
 {\$2.99}% value
% the next value needs to be expanded:
\DTLsetup{new-value-expand}
\DTLnewdbentry
 {mydata}% database label
 {Notes}% column key
 {\limiteded}% value
% switch off expansion:
\DTLsetup{new-value-expand=false}
\DTLnewrow{mydata}% create a new row
% Add entries to the third row:
\DTLnewdbentry
 {mydata}% database label
 {Product}% column key
 {The Return of Sir Quackalot}% value
\DTLnewdbentry
 {mydata}% database label
 {Quantity}% column key
 {3}% value
\DTLnewdbentry
 {mydata}% database label
 {Price}% column key
 {\$4.99}% value
 
\begin{document}
\DTLdisplaydb{mydata}
\end{document}
