SlideShare a Scribd company logo
Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.com
Practical SQL A Beginner s Guide to Storytelling
with Data 2nd Edition Anthony Debarros
https://ebookmeta.com/product/practical-sql-a-beginner-s-
guide-to-storytelling-with-data-2nd-edition-anthony-
debarros-2/
OR CLICK HERE
DOWLOAD EBOOK
Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com
Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.
Practical SQL A Beginner s Guide to Storytelling with Data
2nd Edition Anthony Debarros
https://ebookmeta.com/product/practical-sql-a-beginner-s-guide-to-
storytelling-with-data-2nd-edition-anthony-debarros/
ebookmeta.com
Practical SQL: A Beginner's Guide to Storytelling with
Data, 2nd Edition Anthony Debarros
https://ebookmeta.com/product/practical-sql-a-beginners-guide-to-
storytelling-with-data-2nd-edition-anthony-debarros/
ebookmeta.com
SQL QuickStart Guide The Simplified Beginner s Guide to
Managing Analyzing and Manipulating Data With SQL Walter
Shields
https://ebookmeta.com/product/sql-quickstart-guide-the-simplified-
beginner-s-guide-to-managing-analyzing-and-manipulating-data-with-sql-
walter-shields/
ebookmeta.com
Nephilim Prince 2 A Men s Fantasy Series Dark Star Series
1st Edition Troy Maverick
https://ebookmeta.com/product/nephilim-prince-2-a-men-s-fantasy-
series-dark-star-series-1st-edition-troy-maverick/
ebookmeta.com
Take Control of iOS 15 and iPadOS 15 Josh Centers
https://ebookmeta.com/product/take-control-of-ios-15-and-
ipados-15-josh-centers/
ebookmeta.com
Quantum Mechanics Mahesh C Jain
https://ebookmeta.com/product/quantum-mechanics-mahesh-c-jain/
ebookmeta.com
Always Eli Forever Love 1 1st Edition Charlie Novak
https://ebookmeta.com/product/always-eli-forever-love-1-1st-edition-
charlie-novak/
ebookmeta.com
The Godsfall Chronicles 1st Edition Cocooned Cow
https://ebookmeta.com/product/the-godsfall-chronicles-1st-edition-
cocooned-cow/
ebookmeta.com
Marginal Urbanisms Informal and Formal Development in
Cities of Latin America 1st Edition Felipe Hernández
https://ebookmeta.com/product/marginal-urbanisms-informal-and-formal-
development-in-cities-of-latin-america-1st-edition-felipe-hernandez/
ebookmeta.com
The Eye of the Crown Routledge Research in Early Modern
History 1st Edition Kristin M.S. Bezio
https://ebookmeta.com/product/the-eye-of-the-crown-routledge-research-
in-early-modern-history-1st-edition-kristin-m-s-bezio/
ebookmeta.com
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthony Debarros
CONTENTS IN DETAIL
TITLE PAGE
COPYRIGHT
ABOUT THE AUTHOR
PREFACE TO THE SECOND EDITION
ACKNOWLEDGMENTS
INTRODUCTION
What Is SQL?
Why SQL?
Who Is This Book For?
What You’ll Learn
CHAPTER 1: SETTING UP YOUR CODING ENVIRONMENT
Installing a Text Editor
Downloading Code and Data from GitHub
Installing PostgreSQL and pgAdmin
Windows Installation
macOS Installation
Linux Installation
Working with pgAdmin
Launching pgAdmin and Setting a Master Password
Connecting to the Default postgres Database
Exploring the Query Tool
Customizing pgAdmin
Alternatives to pgAdmin
Wrapping Up
CHAPTER 2: CREATING YOUR FIRST DATABASE AND TABLE
Understanding Tables
Creating a Database
Executing SQL in pgAdmin
Connecting to the analysis Database
Creating a Table
Using the CREATE TABLE Statement
Making the teachers Table
Inserting Rows into a Table
Using the INSERT Statement
Viewing the Data
Getting Help When Code Goes Bad
Formatting SQL for Readability
Wrapping Up
CHAPTER 3: BEGINNING DATA EXPLORATION WITH SELECT
Basic SELECT Syntax
Querying a Subset of Columns
Sorting Data with ORDER BY
Using DISTINCT to Find Unique Values
Filtering Rows with WHERE
Using LIKE and ILIKE with WHERE
Combining Operators with AND and OR
Putting It All Together
Wrapping Up
CHAPTER 4: UNDERSTANDING DATA TYPES
Understanding Characters
Understanding Numbers
Using Integers
Auto-Incrementing Integers
Using Decimal Numbers
Choosing Your Number Data Type
Understanding Dates and Times
Using the interval Data Type in Calculations
Understanding JSON and JSONB
Using Miscellaneous Types
Transforming Values from One Type to Another with CAST
Using CAST Shortcut Notation
Wrapping Up
CHAPTER 5: IMPORTING AND EXPORTING DATA
Working with Delimited Text Files
Handling Header Rows
Quoting Columns That Contain Delimiters
Using COPY to Import Data
Importing Census Data Describing Counties
Creating the us_counties_pop_est_2019 Table
Understanding Census Columns and Data Types
Performing the Census Import with COPY
Inspecting the Import
Importing a Subset of Columns with COPY
Importing a Subset of Rows with COPY
Adding a Value to a Column During Import
Using COPY to Export Data
Exporting All Data
Exporting Particular Columns
Exporting Query Results
Importing and Exporting Through pgAdmin
Wrapping Up
CHAPTER 6: BASIC MATH AND STATS WITH SQL
Understanding Math Operators and Functions
Understanding Math and Data Types
Adding, Subtracting, and Multiplying
Performing Division and Modulo
Using Exponents, Roots, and Factorials
Minding the Order of Operations
Doing Math Across Census Table Columns
Adding and Subtracting Columns
Finding Percentages of the Whole
Tracking Percent Change
Using Aggregate Functions for Averages and Sums
Finding the Median
Finding the Median with Percentile Functions
Finding Median and Percentiles with Census Data
Finding Other Quantiles with Percentile Functions
Finding the Mode
Wrapping Up
CHAPTER 7: JOINING TABLES IN A RELATIONAL DATABASE
Linking Tables Using JOIN
Relating Tables with Key Columns
Querying Multiple Tables Using JOIN
Understanding JOIN Types
JOIN
LEFT JOIN and RIGHT JOIN
FULL OUTER JOIN
CROSS JOIN
Using NULL to Find Rows with Missing Values
Understanding the Three Types of Table Relationships
One-to-One Relationship
One-to-Many Relationship
Many-to-Many Relationship
Selecting Specific Columns in a Join
Simplifying JOIN Syntax with Table Aliases
Joining Multiple Tables
Combining Query Results with Set Operators
UNION and UNION ALL
INTERSECT and EXCEPT
Performing Math on Joined Table Columns
Wrapping Up
CHAPTER 8: TABLE DESIGN THAT WORKS FOR YOU
Following Naming Conventions
Quoting Identifiers Enables Mixed Case
Pitfalls with Quoting Identifiers
Guidelines for Naming Identifiers
Controlling Column Values with Constraints
Primary Keys: Natural vs. Surrogate
Foreign Keys
How to Automatically Delete Related Records with CASCADE
The CHECK Constraint
The UNIQUE Constraint
The NOT NULL Constraint
How to Remove Constraints or Add Them Later
Speeding Up Queries with Indexes
B-Tree: PostgreSQL’s Default Index
Considerations When Using Indexes
Wrapping Up
CHAPTER 9: EXTRACTING INFORMATION BY GROUPING
AND SUMMARIZING
Creating the Library Survey Tables
Creating the 2018 Library Data Table
Creating the 2017 and 2016 Library Data Tables
Exploring the Library Data Using Aggregate Functions
Counting Rows and Values Using count()
Finding Maximum and Minimum Values Using max() and min()
Aggregating Data Using GROUP BY
Wrapping Up
CHAPTER 10: INSPECTING AND MODIFYING DATA
Importing Data on Meat, Poultry, and Egg Producers
Interviewing the Dataset
Checking for Missing Values
Checking for Inconsistent Data Values
Checking for Malformed Values Using length()
Modifying Tables, Columns, and Data
Modifying Tables with ALTER TABLE
Modifying Values with UPDATE
Viewing Modified Data with RETURNING
Creating Backup Tables
Restoring Missing Column Values
Updating Values for Consistency
Repairing ZIP Codes Using Concatenation
Updating Values Across Tables
Deleting Unneeded Data
Deleting Rows from a Table
Deleting a Column from a Table
Deleting a Table from a Database
Using Transactions to Save or Revert Changes
Improving Performance When Updating Large Tables
Wrapping Up
CHAPTER 11: STATISTICAL FUNCTIONS IN SQL
Creating a Census Stats Table
Measuring Correlation with corr(Y, X)
Checking Additional Correlations
Predicting Values with Regression Analysis
Finding the Effect of an Independent Variable with r-Squared
Finding Variance and Standard Deviation
Creating Rankings with SQL
Ranking with rank() and dense_rank()
Ranking Within Subgroups with PARTITION BY
Calculating Rates for Meaningful Comparisons
Finding Rates of Tourism-Related Businesses
Smoothing Uneven Data
Wrapping Up
CHAPTER 12: WORKING WITH DATES AND TIMES
Understanding Data Types and Functions for Dates and Times
Manipulating Dates and Times
Extracting the Components of a timestamp Value
Creating Datetime Values from timestamp Components
Retrieving the Current Date and Time
Working with Time Zones
Finding Your Time Zone Setting
Setting the Time Zone
Performing Calculations with Dates and Times
Finding Patterns in New York City Taxi Data
Finding Patterns in Amtrak Data
Wrapping Up
CHAPTER 13: ADVANCED QUERY TECHNIQUES
Using Subqueries
Filtering with Subqueries in a WHERE Clause
Creating Derived Tables with Subqueries
Joining Derived Tables
Generating Columns with Subqueries
Understanding Subquery Expressions
Using Subqueries with LATERAL
Using Common Table Expressions
Performing Cross Tabulations
Installing the crosstab() Function
Tabulating Survey Results
Tabulating City Temperature Readings
Reclassifying Values with CASE
Using CASE in a Common Table Expression
Wrapping Up
CHAPTER 14: MINING TEXT TO FIND MEANINGFUL DATA
Formatting Text Using String Functions
Case Formatting
Character Information
Removing Characters
Extracting and Replacing Characters
Matching Text Patterns with Regular Expressions
Regular Expression Notation
Using Regular Expressions with WHERE
Regular Expression Functions to Replace or Split Text
Turning Text to Data with Regular Expression Functions
Full-Text Search in PostgreSQL
Text Search Data Types
Creating a Table for Full-Text Search
Searching Speech Text
Ranking Query Matches by Relevance
Wrapping Up
CHAPTER 15: ANALYZING SPATIAL DATA WITH POSTGIS
Enabling PostGIS and Creating a Spatial Database
Understanding the Building Blocks of Spatial Data
Understanding Two-Dimensional Geometries
Well-Known Text Formats
Projections and Coordinate Systems
Spatial Reference System Identifier
Understanding PostGIS Data Types
Creating Spatial Objects with PostGIS Functions
Creating a Geometry Type from Well-Known Text
Creating a Geography Type from Well-Known Text
Using Point Functions
Using LineString Functions
Using Polygon Functions
Analyzing Farmers’ Markets Data
Creating and Filling a Geography Column
Adding a Spatial Index
Finding Geographies Within a Given Distance
Finding the Distance Between Geographies
Finding the Nearest Geographies
Working with Census Shapefiles
Understanding the Contents of a Shapefile
Loading Shapefiles
Exploring the Census 2019 Counties Shapefile
Examining Demographics Within a Distance
Performing Spatial Joins
Exploring Roads and Waterways Data
Joining the Census Roads and Water Tables
Finding the Location Where Objects Intersect
Wrapping Up
CHAPTER 16: WORKING WITH JSON DATA
Understanding JSON Structure
Considering When to Use JSON with SQL
Using json and jsonb Data Types
Importing and Indexing JSON Data
Using json and jsonb Extraction Operators
Key Value Extraction
Array Element Extraction
Path Extraction
Containment and Existence
Analyzing Earthquake Data
Exploring and Loading the Earthquake Data
Working with Earthquake Times
Finding the Largest and Most-Reported Earthquakes
Converting Earthquake JSON to Spatial Data
Generating and Manipulating JSON
Turning Query Results into JSON
Adding, Updating, and Deleting Keys and Values
Using JSON Processing Functions
Finding the Length of an Array
Returning Array Elements as Rows
Wrapping Up
CHAPTER 17: SAVING TIME WITH VIEWS, FUNCTIONS, AND
TRIGGERS
Using Views to Simplify Queries
Creating and Querying Views
Creating and Refreshing a Materialized View
Inserting, Updating, and Deleting Data Using a View
Creating Your Own Functions and Procedures
Creating the percent_change() Function
Using the percent_change() Function
Updating Data with a Procedure
Using the Python Language in a Function
Automating Database Actions with Triggers
Logging Grade Updates to a Table
Automatically Classifying Temperatures
Wrapping Up
CHAPTER 18: USING POSTGRESQL FROM THE COMMAND
LINE
Setting Up the Command Line for psql
Windows psql Setup
macOS psql Setup
Linux psql Setup
Working with psql
Launching psql and Connecting to a Database
Running SQL Queries on psql
Navigating and Formatting Results
Meta-Commands for Database Information
Importing, Exporting, and Using Files
Additional Command Line Utilities to Expedite Tasks
Adding a Database with createdb
Loading Shapefiles with shp2pgsql
Wrapping Up
CHAPTER 19: MAINTAINING YOUR DATABASE
Recovering Unused Space with VACUUM
Tracking Table Size
Monitoring the Autovacuum Process
Running VACUUM Manually
Reducing Table Size with VACUUM FULL
Changing Server Settings
Locating and Editing postgresql.conf
Reloading Settings with pg_ctl
Backing Up and Restoring Your Database
Using pg_dump to Export a Database or Table
Restoring a Database Export with pg_restore
Exploring Additional Backup and Restore Options
Wrapping Up
CHAPTER 20: TELLING YOUR DATA’S STORY
Start with a Question
Document Your Process
Gather Your Data
No Data? Build Your Own Database
Assess the Data’s Origins
Interview the Data with Queries
Consult the Data’s Owner
Identify Key Indicators and Trends over Time
Ask Why
Communicate Your Findings
Wrapping Up
APPENDIX: ADDITIONAL POSTGRESQL RESOURCES
PostgreSQL Development Environments
PostgreSQL Utilities, Tools, and Extensions
PostgreSQL News and Community
Documentation
INDEX
PRACTICAL SQL
2nd Edition
A Beginner’s Guide to Storytelling
with Data
by Anthony DeBarros
PRACTICAL SQL, 2ND EDITION. Copyright © 2022 by Anthony DeBarros.
All rights reserved. No part of this work may be reproduced or transmitted in any
form or by any means, electronic or mechanical, including photocopying,
recording, or by any information storage or retrieval system, without the prior
written permission of the copyright owner and the publisher.
Printed in the United States of America
First printing
25 24 23 22 21 1 2 3 4 5 6 7 8 9
ISBN-13: 978-1-7185-0106-5 (print)
ISBN-13: 978-1-7185-0107-2 (ebook)
Publisher: William Pollock
Managing Editor: Jill Franklin
Production Manager: Rachel Monaghan
Production Editors: Jennifer Kepler and Paula Williamson
Developmental Editor: Liz Chadwick
Cover Illustrator: Josh Ellingson
Interior Design: Octopod Studios
Technical Reviewer: Stephen Frost
Copyeditor: Kim Wimpsett
Compositor: Maureen Forys, Happenstance Type-O-Rama
Proofreader: Liz Wheeler
For information on book distributors or translations, please contact No Starch
Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1.415.863.9900; info@nostarch.com
www.nostarch.com
The Library of Congress has catalogued the first edition as follows:
Names: DeBarros, Anthony, author.
Title: Practical SQL : a beginner's guide to storytelling with data /
Anthony DeBarros.
Description: San Francisco : No Starch Press, 2018. | Includes index.
Identifiers: LCCN 2018000030 (print) | LCCN 2017043947 (ebook) | ISBN
9781593278458 (epub) | ISBN
1593278454 (epub) | ISBN 9781593278274 (paperback) | ISBN 1593278276
(paperback) | ISBN 9781593278458
(ebook)
Subjects: LCSH: SQL (Computer program language) | Database design. | BISAC:
COMPUTERS / Programming
Languages / SQL. | COMPUTERS / Database Management / General. | COMPUTERS
/ Database Management
/ Data Mining.
Classification: LCC QA76.73.S67 (print) | LCC QA76.73.S67 D44 2018 (ebook) |
DDC 005.75/6--dc23
LC record available at https://lccn.loc.gov/2018000030
No Starch Press and the No Starch Press logo are registered trademarks of No
Starch Press, Inc. Other product and company names mentioned herein may be
the trademarks of their respective owners. Rather than use a trademark symbol
with every occurrence of a trademarked name, we are using the names only in an
editorial fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
The information in this book is distributed on an “As Is” basis, without warranty.
While every precaution has been taken in the preparation of this work, neither the
author nor No Starch Press, Inc. shall have any liability to any person or entity
with respect to any loss or damage caused or alleged to be caused directly or
indirectly by the information contained in it.
About the Author
Anthony DeBarros is a longtime journalist and early adopter of “data
journalism,” the use of spreadsheets, databases, and code to find
news in data. He’s currently a data editor for the Wall Street Journal,
where he covers topics including the economy, trade, demographics,
and the Covid-19 pandemic. Previously, he worked for the Gannett
company at USA Today and the Poughkeepsie Journal and held
product development and content strategy roles for Questex and
DocumentCloud.
About the Technical Reviewer
Stephen Frost is the chief technology officer at Crunchy Data. He has
been working with PostgreSQL since 2003 and general database
technology since before then. Stephen began contributing to
PostgreSQL development in 2004 and has been involved in the
development of the role system, column-level privileges, row-level
security, GSSAPI encryption, and the predefined roles system. He
has also served on the board of the United States PostgreSQL
Association and Software in the Public Interest, regularly speaks at
PostgreSQL Community conferences and events, and works as a
member of various PostgreSQL community teams.
PREFACE TO THE SECOND EDITION
Since the publication of the first edition of Practical
SQL, I’ve received kind notes about the book from
readers around the world. One happy reader said it
helped him ace SQL questions on a job interview.
Another, a teacher, wrote to say that his students
remarked favorably about having the book assigned
for class. Others just wanted to say thanks because
they found the book helpful and a good read, two
pieces of feedback that will warm the heart of most
any author.
I also sometimes heard from readers who hit a roadblock while
working through an exercise or who had trouble with software or
data files. I paid close attention to those emails, especially when the
same question seemed to crop up more than once. Meanwhile,
during my own journey of learning SQL—I use it every day at work—
I’d often discover a technique and wish that I’d included it in the
book.
With all that in mind, I approached the team at No Starch Press with
the idea of updating and expanding Practical SQL into a second
edition. I’m thankful they said yes. This new version of the book is
more complete, offers stronger guidance for readers related to
software and code, and clarifies information that wasn’t as clear or
presented as accurately as it could have been. The book has been
thoroughly enjoyable to revisit, and I’ve learned much along the
way.
This second edition includes numerous updates, expansions, and
clarifications in every chapter. Throughout, I’ve been careful to note
when code syntax adheres to the SQL standard—meaning you can
generally use it across database systems—or when the syntax is
specific to the database used in the book, PostgreSQL.
The following are among the most substantial changes:
Two chapters are new. Chapter 1, “Setting Up Your Coding
Environment,” details how to install PostgreSQL, pgAdmin, and
additional PostgreSQL components on multiple operating systems. It
also shows how to obtain the code listings and data from GitHub. In
the first edition, this information was located in the introduction and
occasionally missed by readers. Chapter 16, “Working with JSON
Data,” covers PostgreSQL’s support for the JavaScript Object
Notation data format, using datasets about movies and earthquakes.
In Chapter 4 on data types, I’ve added a section on IDENTITY, the
ANSI SQL standard implementation for auto-incrementing integer
columns. Throughout the book, IDENTITY replaces the PostgreSQL-
specific serial auto-incrementing integer type so that code
examples more closely reflect the SQL standard.
Chapter 5 on importing and exporting data now includes a section
about using the WHERE keyword with the COPY command to filter
which rows are imported from a source file to a table.
I’ve removed the user-created median() function from Chapter 6 on
basic math in favor of focusing exclusively on the SQL standard
percentile_cont() function for calculating medians.
In Chapter 7 on table joins, I’ve added a section covering the set
operators UNION, UNION ALL, INTERSECT, and EXCEPT. Additionally, I’ve
added a section covering the USING clause in joins to reduce
redundant output and simplify query syntax.
Chapter 10 on inspecting and modifying data includes a new section
on using the RETURNING keyword in an UPDATE statement to display
the data that the statement modified. I’ve also added a section that
describes how to use the TRUNCATE command to remove all rows
from a table and restart an IDENTITY sequence.
In Chapter 11 on statistical functions, a new section demonstrates
how to create a rolling average to smooth uneven data to get a
better sense of trends over time. I’ve also added information on
functions for calculating standard deviation and variance.
Chapter 13 on advanced query techniques now shows how to use
the LATERAL keyword with subqueries. One benefit is that, by
combining LATERAL with JOIN, you get functionality similar to a for
loop in a programming language.
In Chapter 15 on analyzing spatial data, I demonstrate how to use
the Geometry Viewer in pgAdmin to see geographies placed on a
map. This feature was added to pgAdmin after publication of the
first edition.
In Chapter 17 on views, functions, and triggers, I’ve added
information about materialized views and showed how their behavior
differs from standard views. I also cover procedures, which
PostgreSQL now supports in addition to functions.
Finally, where practical, datasets have been updated to the most
recent available at the time of writing. This primarily applies to US
Census population statistics but also includes the text of presidential
speeches and library usage statistics.
Thank you for reading Practical SQL! If you have any questions or
feedback, please get in touch by emailing
practicalsqlbook@gmail.com.
ACKNOWLEDGMENTS
This second edition of Practical SQL is the work of many hands. My
thanks, first, go to the team at No Starch Press. Thanks to Bill
Pollock for capturing the vision and sharpening the initial concept for
the book—and for agreeing to let me have another go at it. Special
thanks and appreciation to senior editor Liz Chadwick, who improved
each chapter with her insightful suggestions and deft editing, and to
copyeditor Kim Wimpsett and the production team of Paula
Williamson and Jennifer Kepler.
Stephen Frost, chief technology officer at Crunchy Data and longtime
contributor to the PostgreSQL community, served as the technical
reviewer for this edition. I deeply appreciate the time Stephen took
to explain the inner workings of PostgreSQL and SQL concepts. This
book is better, more thorough, and more accurate thanks to his
detailed eye. I’d also like to acknowledge Josh Berkus, whose many
contributions as technical reviewer for the first edition persist in this
new version.
Thank you to Investigative Reporters and Editors (IRE) and its
members and staff past and present for training journalists to find
stories in data. IRE is where I got my start with SQL and data
journalism.
Many of my colleagues have not only imparted memorable lessons
on data analysis, they’ve also made my workdays brighter. Special
thanks to Paul Overberg for sharing his vast knowledge of
demographics and the US Census, to Lou Schilling for many
technical lessons, to Christopher Schnaars for his SQL expertise, to
Peter Matseykanets for his encouragement, and to Chad Day, John
West, and Maureen Linke and the WSJ DC visuals team for continual
inspiration.
My deepest appreciation goes to my dear wife, Elizabeth, and our
sons. You are the brightest lights in my day. As we are fond of
saying, “To the journey . . .”
INTRODUCTION
Shortly after joining the staff of USA
Today, I received a dataset that I would
analyze almost every week for the next
decade. It was the weekly Best-Selling
Books list, which ranked the nation’s
top-selling titles based on confidential sales data. Not
only did the list produce an endless stream of story
ideas to pitch, it also captured the zeitgeist of
America in a singular way.
Did you know that cookbooks sell a bit more during the week of
Mother’s Day or that Oprah Winfrey turned many obscure writers
into number-one best-selling authors just by having them on her
show? Every week, the book list editor and I pored over the sales
figures and book genres, ranking the data in search of a new
headline. Rarely did we come up empty: we chronicled everything
from the rocket-rise of the blockbuster Harry Potter series to the fact
that Oh, the Places You’ll Go! by Dr. Seuss had become a perennial
gift for new graduates.
My technical companion in that time was the database programming
language SQL (for Structured Query Language). Early on, I
convinced USA Today’s IT department to grant me access to the
SQL-based database system that powered our book list application.
Using SQL, I was able to discover the stories hidden in the database,
which contained sales data related to titles, authors, genres, and the
codes that defined the publishing world.
SQL has been useful to me ever since, whether my role was in
product development, in content strategy, or, lately, as a data editor
for the Wall Street Journal. In each case, SQL has helped me find
interesting stories in data—and that’s exactly what you’ll learn to do
using this book.
What Is SQL?
SQL is a widely used programming language for managing data and
database systems. Whether you’re a marketing analyst, a journalist,
or a researcher mapping neurons in the brain of a fruit fly, you’ll
benefit from using SQL to collect, modify, explore, and summarize
data.
Because SQL is a mature language that’s been around for decades,
it’s ingrained in many modern systems. A pair of IBM researchers
first outlined the syntax for SQL (then called SEQUEL) in a 1974
paper, building on the theoretical work of the British computer
scientist Edgar F. Codd. In 1979, a precursor to the database
company Oracle (then called Relational Software) became the first to
use the language in a commercial product. Today, SQL still ranks as
one of the most-used computer languages in the world, and that’s
unlikely to change soon.
Each database system, such as PostgreSQL, MySQL or Microsoft SQL
Server, implements its own variant of SQL, so you’ll notice subtle—or
sometimes significant—differences in syntax if you jump from one
system to another. There are several reasons behind this. The
American National Standards Institute (ANSI) adopted a standard for
SQL in 1986, followed by the International Organization for
Standardization (ISO) in 1987. But the standard doesn’t cover all
aspects of SQL that are required for a database implementation—for
example, it has no entry for creating indexes. That leaves each
database system maker to choose how to implement features the
standard doesn’t cover—and no database maker currently claims to
conform to the entire standard.
Meanwhile, business considerations can lead commercial database
vendors to create nonstandard SQL features for both competitive
advantage and as a way to keep users in their ecosystem. For
example, Microsoft’s SQL Server uses the proprietary Transact-SQL
(T-SQL) that includes a number of features not in the SQL standard,
such as its syntax for declaring local variables. Migrating code
written using T-SQL to another database system may not be trivial,
therefore.
In this book, the examples and code use the PostgreSQL database
system. PostgreSQL, or simply Postgres, is a robust application that
can handle large amounts of data. Here are some reasons
PostgreSQL is a great choice to use with this book:
It’s free.
It’s available for Windows, macOS, and Linux operating systems.
Its SQL implementation aims to closely follow the SQL standard.
It’s widely used, so finding help online is easy.
Its geospatial extension, PostGIS, lets you analyze geometric data
and perform mapping functions and is often used with mapping
software such as QGIS.
It’s available in cloud computing environments such as Amazon Web
Services and Google Cloud.
It’s a common choice as a data store for web applications, including
those powered by the popular web framework Django.
The good news is that the fundamental concepts and much of the
core SQL syntactical conventions of PostgreSQL will work across
databases. So, if you’re using MySQL at work, you can employ much
of what you learn here—or easily find parallel code concepts. When
syntax is PostgreSQL-specific, I make sure to point that out. If you
need to learn the SQL syntax of a system with features that deviate
from the standard, such as Microsoft SQL Server’s T-SQL, you may
want to further explore a resource focusing on that system.
Why SQL?
SQL certainly isn’t the only option for crunching data. Many people
start with Microsoft Excel spreadsheets and their assortment of
analytic functions. After working with Excel, they might graduate to
Access, the database system built into some versions of Microsoft
Office, which has a graphical query interface that makes it easy to
get work done. So why learn SQL?
One reason is that Excel and Access have their limits. Excel currently
allows 1,048,576 rows maximum per worksheet. Access limits
database size to two gigabytes and limits columns to 255 per table.
It’s not uncommon for datasets to surpass those limits. The last
obstacle you want to discover while facing a deadline is that your
database system doesn’t have the capacity to get the job done.
Using a robust SQL database system allows you to work with
terabytes of data, multiple related tables, and thousands of columns.
It gives you fine-grained control over the structure of your data,
leading to efficiency, speed, and—most important—accuracy.
SQL is also an excellent adjunct to programming languages used in
the data sciences, such as R and Python. If you use either language,
you can connect to SQL databases and, in some cases, even
incorporate SQL syntax directly into the language. For people with
no background in programming languages, SQL often serves as an
easy-to-understand introduction into concepts related to data
structures and programming logic.
Finally, SQL is useful beyond data analysis. If you delve into building
online applications, you’ll find that databases provide the backend
power for many common web frameworks, interactive maps, and
content management systems. When you need to dig beneath the
surface of these applications, the ability to manage data and
databases with SQL will come in very handy.
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthony Debarros
Who Is This Book For?
Practical SQL is for people who encounter data in their everyday
lives and want to learn how to analyze, manage, and transform it.
With that in mind, we cover real-world data and scenarios, such as
US Census demographics, crime reports, and data about taxi rides in
New York City. We aim to understand not only how SQL works but
how we can use it to find valuable insights.
This book was written with people new to programming in mind, so
the early chapters cover key basics about databases, data, and SQL
syntax. Readers with some SQL experience should benefit from later
chapters that cover more advanced topics, such as Geographical
Information Systems (GIS). I assume that you know your way
around your computer, including how to install programs, navigate
your hard drive, and download files from the internet, but I don’t
assume you have any experience with programming or data analysis.
What You’ll Learn
Practical SQL starts with a chapter on setting up your system and
getting the code and data examples and then moves through the
basics of databases, queries, tables, and data that are common to
SQL across many database systems. Chapters 14 to 19 cover topics
more specific to PostgreSQL, such as full-text search, functions, and
GIS. Although many chapters in this book can stand alone, you
should work through the book sequentially to build on the
fundamentals. Datasets presented in early chapters often reappear
later, so following the book in order will help you stay on track.
The following summary provides more detail about each chapter:
Chapter 1: Setting Up Your Coding Environment walks through
setting up PostgreSQL, the pgAdmin user interface, and a text editor,
plus how to download example code and data.
Chapter 2: Creating Your First Database and Table provides
step-by-step instructions for the process of loading a simple dataset
about teachers into a new database.
Chapter 3: Beginning Data Exploration with SELECT explores
basic SQL query syntax, including how to sort and filter data.
Chapter 4: Understanding Data Types explains the definitions
for setting columns in a table to hold specific types of data, from
text to dates to various forms of numbers.
Chapter 5: Importing and Exporting Data explains how to use
SQL commands to load data from external files and then export it.
You’ll load a table of US Census population data that you’ll use
throughout the book.
Chapter 6: Basic Math and Stats with SQL covers arithmetic
operations and introduces aggregate functions for finding sums,
averages, and medians.
Chapter 7: Joining Tables in a Relational Database explains
how to query multiple, related tables by joining them on key
columns. You’ll learn how and when to use different types of joins.
Chapter 8: Table Design that Works for You covers how to set
up tables to improve the organization and integrity of your data as
well as how to speed up queries using indexes.
Chapter 9: Extracting Information by Grouping and
Summarizing explains how to use aggregate functions to find
trends in US library usage based on annual surveys.
Chapter 10: Inspecting and Modifying Data explores how to
find and fix incomplete or inaccurate data using a collection of
records about meat, egg, and poultry producers as an example.
Chapter 11: Statistical Functions in SQL introduces correlation,
regression, ranking, and other functions to help you derive more
meaning from datasets.
Chapter 12: Working with Dates and Times explains how to
create, manipulate, and query dates and times in your database,
including working with time zones and with data about New York
City taxi trips and Amtrak train schedules.
Chapter 13: Advanced Query Techniques explains how to use
more complex SQL operations such as subqueries and cross
tabulations, plus the CASE statement, to reclassify values in a dataset
on temperature readings.
Chapter 14: Mining Text to Find Meaningful Data covers how
to use PostgreSQL’s full-text search engine and regular expressions
to extract data from unstructured text, using police reports and a
collection of speeches by US presidents as examples.
Chapter 15: Analyzing Spatial Data with PostGIS introduces
data types and queries related to spatial objects, which will let you
analyze geographical features such as counties, roads, and rivers.
Chapter 16: Working with JSON Data introduces the JavaScript
Object Notation (JSON) data format and uses data about movies and
earthquakes to explore PostgreSQL JSON support.
Chapter 17: Saving Time with Views, Functions, and
Triggers explains how to automate database tasks so you can avoid
repeating routine work.
Chapter 18: Using PostgreSQL from the Command Line
covers how to use text commands at your computer’s command
prompt to connect to your database and run queries.
Chapter 19: Maintaining Your Database provides tips and
procedures for tracking the size of your database, customizing
settings, and backing up data.
Chapter 20: Telling Your Data’s Story provides guidelines for
generating ideas for analysis, vetting data, drawing sound
conclusions, and presenting your findings clearly.
Appendix: Additional PostgreSQL Resources lists software and
documentation to help you grow your skills.
Each chapter ends with a “Try It Yourself” section that contains
exercises to help you reinforce the topics you learned.
Ready? Let’s begin with Chapter 1, “Setting Up Your Coding
Environment.”
1
SETTING UP YOUR CODING
ENVIRONMENT
Let’s begin by installing the resources
you’ll need to complete the exercises in
the book. In this chapter, you’ll install a
text editor, download the example code
and data, and then install the
PostgreSQL database system and its companion
graphical user interface, pgAdmin. I’ll also tell you
how to get help if you need it. When you’re finished,
your computer will have a robust environment for
you to learn how to analyze data with SQL.
Avoid the temptation to skip ahead to the next chapter. My high
school teacher (clearly a fan of alliteration) used to tell us that
“proper planning prevents poor performance.” If you follow all the
steps in this chapter, you’ll avoid headaches later.
Our first task is to set up a text editor suitable for working with data.
Installing a Text Editor
The source data you’ll add to a SQL database is typically stored in
multiple text files, often in a format called comma-separated values
(CSV). You’ll learn more about the CSV format in Chapter 5, in the
section “Working with Delimited Text Files,” but for now let’s make
sure you have a text editor that will let you open those files without
inadvertently harming the data.
Common business applications—word processors and spreadsheet
programs—tend to introduce styles or hidden characters into files
without asking, and that makes using them for data work
problematic, as data software expects data in precise formats. For
example, if you open a CSV file with Microsoft Excel, the program
will automatically alter some data to make it more human-readable;
it will assume, for example, that an item code of 3-09 is a date and
format it as 9-Mar. Text editors deal exclusively with plain text with
no embellishments such as formatting, and for that reason
programmers use them to edit files that hold source code, data, and
software configurations—all cases where you want your text to be
treated as text, and nothing more.
Any text editor should work for the book’s purposes, so if you have a
favorite, feel free to use it. Here are some I have used and
recommend. Except where noted, they are free and available for
macOS, Windows, and Linux.
Visual Studio Code by Microsoft: https://code.visualstudio.com/
Atom by GitHub: https://atom.io/
Sublime Text by Sublime HQ (free to evaluate but requires purchase
for continued use): https://www.sublimetext.com/
Notepad++ by author Don Ho (Windows only): https://notepad-
plus-plus.org/ (note that this is a different application than
Notepad.exe, which comes with Windows)
More advanced users who prefer to work in the command line may
want to use one of these two text editors, which are installed by
default in macOS and Linux:
vim by author Bram Moolenaar and the open source community:
https://www.vim.org/
GNU nano by author Chris Allegretta and the open source
community: https://www.nano-editor.org/
If you don’t have a text editor, download and install one and get
familiar with the basics of opening folders and working with files.
Next, let’s get the book’s example code and data.
Downloading Code and Data from GitHub
All of the code and data you’ll need for working through the book’s
exercises are available for download. To get it, follow these steps:
Visit the book’s page on the No Starch Press website at
https://nostarch.com/practical-sql-2nd-edition/.
On the page, click Download the code from GitHub to visit the
repository on https://github.com/ that holds the material.
On the Practical SQL 2nd Edition page at GitHub, you should see a
Code button. Click it, and then select Download ZIP to save the
ZIP file to your computer. Place it in a location where you can easily
find it, such as your desktop. (If you’re a GitHub user, you can also
clone or fork the repository.)
Unzip the file. You should then see a folder named practical-sql-2-
master that contains the various files and subfolders for the book.
Again, place this folder where you can easily find it.
NOTE
Windows users will need to provide permission for the
PostgreSQL database you will install to read and write to the
contents of the practical-sql-2-master folder. To do so, right-
click the folder, click Properties, and click the Security tab.
Click Edit and then Add. Type the name Everyone into the
object names box and click OK. Highlight Everyone in the
user list, select all boxes under Allow, and then click Apply
and OK.
Inside the practical-sql-2-master folder, for each chapter you’ll find a
subfolder named Chapter_XX (XX is the chapter number). Inside
subfolders, each chapter that includes code examples will also have
a file named Chapter_XX that ends with a .sql extension. This is a
SQL code file that you can open with your text editor or with the
PostgreSQL administrative tool you’ll install later in this chapter. Note
that in the book several code examples are truncated to save space,
but you’ll need the full listing from the .sql file to complete the
exercise. You’ll know an example is truncated when you see --snip-
- in the listing.
The chapter folders also contain the public data you’ll use in the
exercises, stored in CSV and other text-based files. As noted, it’s fine
to view CSV files with a true text editor, but don’t open these files
with Excel or a word processor.
Now, with the prerequisites complete, let’s load the database
software.
Installing PostgreSQL and pgAdmin
In this section, you’ll install both the PostgreSQL database system
and a companion graphical administrative tool, pgAdmin. Think of
pgAdmin as a helpful visual workspace for managing your
PostgreSQL database. Its interface lets you see your database
objects, manage settings, import and export data, and write queries,
which is the code that retrieves data from your database.
One benefit of using PostgreSQL is that the open source community
has provided excellent guidelines that make it easy to get
PostgreSQL up and running. The following sections outline
installation for Windows, macOS, and Linux as of this writing, but
the steps might change as new versions of the software or operating
systems are released. Check the documentation noted in each
section as well as the GitHub repository with the book’s resources;
I’ll maintain files there with updates and answers to frequently asked
questions.
NOTE
I recommend you install the latest available version of
PostgreSQL for your operating system to ensure that it’s up-
to-date on security patches and new features. For this book,
I’ll assume you’re using version 11.0 or later.
Windows Installation
For Windows, I recommend using the installer provided by the
company EDB (formerly EnterpriseDB), which offers support and
services for PostgreSQL users. When you download the PostgreSQL
package bundle from EDB, you also get pgAdmin and Stack Builder,
which includes a few other tools you’ll use in this book and
throughout your SQL career.
To get the software, visit
https://www.postgresql.org/download/windows/ and click
Download the installer in the EDB section. This should lead to a
downloads page on the EDB site. Select the latest available 64-bit
Windows version of PostgreSQL unless you’re using an older PC with
32-bit Windows.
NOTE
The following section covers installation for Windows 10. If
you’re using Windows 11, please check the GitHub repository
with the book’s resources for notes about any adjustments to
these instructions.
After you download the installer, follow these steps to install
PostgreSQL, pgAdmin, and additional components:
Right-click the installer and select Run as administrator. Answer
Yes to the question about allowing the program to make changes to
your computer. The program will perform a setup task and then
present an initial welcome screen. Click through it.
Choose your installation directory, accepting the default.
On the Select Components screen, select the boxes to install
PostgreSQL Server, the pgAdmin tool, Stack Builder, and the
command line tools.
Choose the location to store data. You can choose the default, which
is in a data subdirectory in the PostgreSQL directory.
Choose a password. PostgreSQL is robust with security and
permissions. This password is for the default initial database
superuser account, which is called postgres.
Select the default port number where the server will listen. Unless
you have another database or application using it, use the default,
which should be 5432. You can substitute 5433 or another number if
you already have an application using the default port.
Select your locale. Using the default is fine. Then click through the
summary screen to begin the installation, which will take several
minutes.
When the installation is done, you’ll be asked whether you want to
launch EnterpriseDB’s Stack Builder to obtain additional packages.
Make sure the box is checked and click Finish.
When Stack Builder launches, choose the PostgreSQL installation on
the drop-down menu and click Next. A list of additional applications
should download.
Expand the Spatial Extensions menu and select the PostGIS Bundle
for the version of PostgreSQL you installed. You may see more than
one listed; if so, choose the newest version. Also, expand the Add-
ons, tools and utilities menu and select EDB Language Pack,
which installs support for programming languages including Python.
Click through several times; you’ll need to wait while the installer
downloads the additional components.
When installation files have been downloaded, click Next to install
the language and PostGIS components. For PostGIS, you’ll need to
agree to the license terms; click through until you’re asked to
Choose Components. Make sure PostGIS and Create spatial database
are selected. Click Next, accept the default install location, and click
Next again.
Enter your database password when prompted and continue through
the prompts to install PostGIS.
Answer Yes when asked to register the PROJ_LIB and GDAL_DATA
environment variables. Also, answer Yes to the questions about
setting POSTGIS_ENABLED_DRIVERS and enabling the
POSTGIS_ENABLE_OUTDB_RASTERS environment variable. Finally, click
through the final Finish steps to complete the installation and exit
the installers. Depending on the version, you may be prompted to
restart your computer.
When finished, you should have two new folders in your Windows
Start menu: one for PostgreSQL and another for PostGIS.
If you’d like to get started right away, you can skip ahead to the
section “Working with pgAdmin.” Otherwise, follow the steps in the
next section to set environment variables for optional Python
language support. We cover using Python with PostgreSQL in
Discovering Diverse Content Through
Random Scribd Documents
deadly work they had begun, was hourly expected; but they did not
come, and at last it dawned upon the minds of those in authority
that, seeing they were within entrenchments, a smaller number of
soldiers might serve to guard them. It took some time for this idea
to work in the official mind; but, at last, to the intense satisfaction of
the soldiers and regimental officers, five hundred men were told off
to join the English force which was supposed to be marching on
Delhi.
It was on the 23rd that the General encountered the detachment
from his mutinous regiment in the wood; and, early on the 24th, the
force from Meerut was to be in readiness to march. Hence the
ambush. The rebels, whose intelligence department was much better
managed than ours—they had spies everywhere—knowing exactly
what was going to happen, had imagined that, through the General,
whom, they believed, they could easily entrap, they might paralyse
the action of the English, so far, at least, as to delay, for some days,
the march of a detachment from Meerut.
They had, as we have seen, most grossly miscalculated. But,
meanwhile, the firing had been heard at Meerut, and a gallant young
officer, well known to the General, who had been burning to
distinguish himself and to redeem the honour of the English arms,
gained permission to go out and reconnoitre with a party of fifty
horsemen.
It was late in the evening; but the moon was well up, and there was
light enough to guide them to the scene of the little skirmish. It was
over by the time they rode out upon the plain. The General and his
men had taken their own vengeance; but, exhausted as they were,
their chief wounded, their horses dead-beat, and their situation
precarious—since, for all they knew to the contrary, the woods
behind them might be full of rebels—the sight of this little band of
their countrymen coming out to meet them was, beyond expression,
cheering.
'They are not all dead then, thank God!' said the General. 'Two of
you gallop out to meet them, boys, and tell them how it is with us.'
'Can you sit a horse, sir,' said Tommy, 'or shall we send for a litter?'
'Litter! Nonsense! I'm not going to give up the ghost yet,' said the
old soldier, testily. 'But,' to himself, 'I shan't mind being at home. I
believe the scoundrel spoke the truth so far. Poor little monkeys! I
wonder which of them is hurt. Oh, God, if I had only listened to
reason, and left them all at home!'
'Do you want anything, sir?' said one of his men, who saw him
speaking, but could not catch his voice.
'No, thank you,' he answered, 'except to get away from this. Ah!
here they are! Friends this time, not foes! Welcome, Bertie,' to the
young officer, who had sprung from his horse, and was looking down
upon him mournfully. 'Don't look so glum, you young rascal. They
are safe?' sharply.
'Your people escaped, General. One of the young ladies was hurt,
not seriously, I believe. Lady Elton has been in the most terrible
state of anxiety.'
'No doubt! No doubt! Well, I shall hear all about it from themselves
soon. Lift me into a saddle, Bertie. We'd better be moving.'
Kullum Khan, who was sobbing like a child, took the General under
one arm, the young officer under the other, and in a few moments
they had him mounted on the quietest and strongest of the horses,
a trooper getting up behind him, to keep him in his place. Then,
carrying the wounded Indians between them, the cavalcade set off
across the plain.
The mango grove where the skirmish had begun was within three
miles of Meerut; but as, for the sake of the wounded, they were
obliged to move slowly, the transit took some time. Scouts,
meanwhile, were thrown out in every direction, to keep the coasts
clear, and warn them of danger. But there was not even an alarm.
The combatants, as the General said grimly, were on their faces, and
the non-combatants kept out of their way.
They came upon the outskirts of Meerut. The General was moaning
heavily, with pain and anguish. There was nothing now to keep up
his proud heart, and it fell.
He knew all the landmarks, and each one had some memory for
him. There was the little grove where, one glorious evening, he and
his men had picnicked when they came down upon Meerut from the
Sikh war, to enjoy a little rest after the hardships of the campaign.
How splendid they had looked, and how handy and helpful they
were, living on next to nothing, and going through fatigue and
privation that would have floored half a European regiment!
And now they were close on the cantonments. He had built several
of the bungalows here and laid out their gardens—the mess-house
for the officers of his regiment, the colonel's house, the spacious and
beautiful bungalow, finished while he was in England, to which only
a few weeks before he had brought his wife and children. This last
was outside cantonments and nearer to the native lines than any
other English house.
He remembered now, pacing slowly and sadly over the blackened
ground, with the charred ruins of what had so lately been a happy
home staring him in the face, how one or two had warned him that,
in case of a rising, the situation would be dangerous, and how
proudly he had smiled at the absurdity of the notion. 'While my
family and I are in the station,' he said, 'a rising would be
impossible, and I don't ask anyone else to occupy the house.' And
now it was literally gutted.
As they were crossing what had been the garden of the General's
bungalow, an old man came out from the ruins and confronted
them. The young officer who, with drawn sword, was leading the
cavalcade, would have swept him aside, but he cried out so
piteously to be heard that the General, who was some yards behind,
ordered that he should be brought to him.
'I think I know your voice,' he said.
'The Sahib should know,' replied the man, weeping bitterly; 'for I
have served him these twenty years.'
'You are Yaseen Khan, my bearer.'
'I am Yaseen Khan, Sahib General, and my son Kullum——'
'I am here, Yaseen,' said the Sepoy from behind. 'I could not go on,
and I slew Koolraj Sing, who tried to deceive me.'
'The gods be praised!' murmured the old man. 'Sahib, by the God
you worship, I beseech you to take me on with you!'
'Why are you here, Yaseen Khan?' said the General.
'Have patience, Excellency, and I will tell you everything. They
surrounded this house and set it on fire in three places. Then I ran
to the lines and called my son, Kullum, who, with Soubahdar Sufder
Jung and others, came up, and the budmashes fled. Trixy Sahib was
hurt; I know not how. They carried her in their arms—my son Kullum
and the Soubahdar—as if she had been their own child. The others
walked, for no carriage was to be found; but the men guarded them
carefully, and not a hair of their heads was touched. I thought of the
General Sahib's gold, and I went back to get it. I could not carry it
away; but I buried it in a secret place. Then the budmashes came
round the house again, yelling like evil spirits. They found me, and
said they would kill me if I did not find them gold. I said I would find
it, and, in going, I escaped. I was close to them, Sahib, and I heard
their cries. They would have torn me to pieces if they had found me;
but there was an alarm. Some one said, "The Sahibs are coming!"
and they ran out, and I saw and heard them no more. But I dared
not move; I kept in hiding, waiting for your Honour's return, and
living on the food I could pick up. For two days I have not eaten.
Have pity on me, Sahib, and take me on!'
'Mount him on one of the horses, and bring him on behind me,' said
the General. 'I believe that what he tells me is the truth.'
A few moments later they came upon the vedettes, and then, the
young officer having answered the challenge, they entered the town.
Here the General insisted upon dismounting.
'I can't present myself to my wife and children in this guise,' he said.
'Dismiss your men to their quarters, Bertie, and let them find
quarters for my men, and for the natives who were faithful. You give
me your arm and we will find Lady Elton.'
The officer gave the necessary directions, adding, on his own
account, that the surgeon of his regiment should be sent to the
General's quarters, and they set off together, the General leaning
heavily on the arm of his guide, and Yaseen Khan, the bearer,
following them.
Lady Elton and her children were under canvas. They had preferred
this arrangement to accepting shelter from any of the houses thrown
open to them, and the Soubahdar and his men having succeeded in
saving many of their things, they had been able already to give their
new quarters a tolerably home-like appearance. It was only in this
way—in exerting themselves to set things straight 'for father,' who,
they felt sure, must come in soon—that the girls could keep their
mother cheerful, or that any of them could chase away the terrible
despondency and shuddering fear which would, at times, take
possession of them. For upon these unfortunate ladies, bred up in
the traditions of the old Anglo-Indian, who looked upon a native as a
cross between a machine and an animal—a creature to be treated
with kindly contempt when he behaved himself, and to be promptly
licked into shape when he did not—the mutiny fell like a bolt of fire
out of a clear sky. They had heard rumours of discontent, but
nothing came of them. They were disposed to think that the
repressive measures had not been sufficiently severe, and when on
May 9 the mutineers of the 3rd Native Cavalry, who had been
condemned by their own countrymen, and sentenced to ten years'
imprisonment, were stripped of their uniform and put in irons, while
sorry for the unhappy men who had been so miserably deluded, they
believed that this one severe example would be sufficient, and that
no more would be heard of mutiny. Lady Elton was fond of quoting
her husband in those days. 'The General says all they want is
firmness. They are the best fellows in the world when you take them
the right way. He ought to know, for he has had so much
experience.' And then Maud would repeat her saucy little phrase
about the riding-whip, and the ladies, who had come to consult
them, would go away reassured. 'You may depend upon it,' they
would say, 'General Elton and his wife know more about these
people than we do.'
To be awakened from this dream of security by the rattle of
musketry from the lines; and, after a few minutes of terror-stricken
silence, the tramp of armed men upon the plain, and the shock of
contending forces, was terrible beyond description. How, stirred up
by Yaseen Khan, who ran in hot haste for his son, they barricaded
themselves into the innermost room of the bungalow, piling furniture
against the doors to keep out the mutineers; how, sitting huddled
together, clasped in one another's arms, they heard the defiant
shouts and yells of rage come nearer and nearer; how Trixy, the first
to recover presence of mind, climbed up to a peep-hole under the
roof, and came back with the awful intelligence that the stables and
kitchens were in flames; how they heard the wretches, who were
mad with bhang and fanaticism, getting on to the roof; then the yell,
when the thatch was torn aside, and one of the fierce creatures
looked down on them; the screams of the girls, and brave little
Trixy's pistol-shot, followed by a shriek from the first scoundrel, and
a shot from the man behind him, which brought the poor girl to the
ground,—all this lives still in these poor women's remembrance as a
dream of horror!
They were rescued as we have seen. Those surrounding the
General's house were budmashes from the bazaars and the criminals
who had rushed out when the gaol doors were opened, and at the
approach of the disciplined force under Soubahdar Sufder Jung
every one of them took to their heels. The ladies, half dead with
fright, and some of their choicest possessions, were escorted safely
to the English barracks, where they lodged that night. Then began
that weary waiting-time, which to poor Lady Elton was even worse
than the scene of horror through which they had passed. Her
husband was away. She had not heard from him for some days, and
did not know where he was. Her beloved eldest daughter Grace and
her niece, only lately married, were in the heart of a district said to
be unsettled before, and which now, when this terrible news from
Meerut went abroad, would be almost certain to rise. She had
friends at Cawnpore, friends at Delhi, friends at Jhansi. None of
them all were so well guarded as they of Meerut. If massacre and
destruction could run riot here, what would it be there?
Day by day she looked for her husband's arrival. She never feared
for his personal safety. She had still the firmest belief in his power
over the native soldiery; but if he came something might be done.
For this made one element in the misery of the old soldier's wife and
daughters. Nothing was being done. 'If I were in command here,'
Trixy would say, clenching her little fists, 'not one of those brutes
should have reached Delhi. Bertie Liston says the men were burning
to be off. He could scarcely keep them quiet. I think I should have
let them go—gone with them.'
'Trixy is a great warrior since she fired that pistol,' said Maud; 'but,
seriously, mother, don't you think something ought to be done?'
'My dear children, be patient! We are women. We know nothing.
Soldiers must obey orders,' said Lady Elton sadly. 'If your father
would only come!'
'He will come soon, mother darling, don't be afraid,' said gentle little
Lucy.
Some such conversation as this had taken place on the afternoon of
the day when firing was heard outside the walls. The five women
heard it distinctly as they sat over their tea in the tent. Then Bertie
Liston came rushing in with a radiant face. 'Good-bye,' he said, 'I am
sent out to reconnoitre. What will you give me if I bring you back
the General?'
'Anything, everything—all we have,' cried Trixy impulsively. She was
lying on a charpoy, for she had not yet recovered from her wound.
Bertie looked at her, and her pale face flushed; but there was time
for no more words. He went out: she heard his horse's hoofs
clattering over the paving-stones in the compound of the barracks,
and covering her face with her hands she burst into tears.
An hour or more passed by. The firing outside had ceased. Nothing
could be heard but the pacing of the sentinels and the chowkedars
crying out one to the other. Darkness had fallen; but the little
company in the tent did not stir. Then Maud, crying out that she
could stand it no longer, lighted a lamp; Trixy, who was very much
ashamed of her little outburst, asked for a book, and Lady Elton fell
back upon her never-failing resource—the silk stockings she was
knitting for the General. 'Do you think, dears,' she said to the two
youngest girls, Lucy and Mildred, 'that you could sing one of your
duets? If father did come home to-night, it would please him to hear
your voices.' They said they would try, and in a few moments their
sweet clear young voices rose above the stillness. It was one of the
sentimental ditties that we used to admire in those days, neither the
words of the song nor the music to which it was set of a particularly
high order; but as, supported by his young friend, the old General
approached the lighted tent, and heard in his girls' sweet voices of
wild waves whispering and red roses fading away, his heart thrilled
with a rapture such as no artistic music could have given. 'Bless
them,' he said, in a low and heartfelt voice. 'All right, isn't it, Bertie?
They couldn't sing like that if the shock had been too much for
them. There! what an old donkey I am! I knew the children had the
pluck of—Come on, Bertie. They are stopping. They hear us. Back,
Yaseen Khan, you old fool! I don't want you to announce me.'
And now the curtain before the tent is thrown aside, and he sees
them—his sweet wife and the children, who are dearer to him than
his life, and his stern eyes fill with tears, and the voice of thunder,
which only a few moments before had roared out defiance to a
hundred foes, is as weak as that of a little child. 'Well, here I am!
How are you all?' he says, feebly.
He is in the gloom; they are in the light. They have not seen, but
they have heard. In a moment they spring up, all but poor Trixy,
who is crying quietly, and there are cries of 'Wilfrid! Thank God!
Father! Father!' And a little voice from the corner is heard to say,
'Bertie has brought him. Don't let Bertie go away!'
All at once there is a lull. They have drawn him under the light, and
they see that his face is pale and drawn, and one of them discovers
that his arm is roughly bandaged. 'Father has been wounded.
Children, don't press round him so,' cries Lady Elton. 'Will some one
run for a doctor?'
'The Doctor Sahib is here,' says a voice outside; a quiet voice, which
contrasts strangely with the agitated tones of those within the tent.
In the next instant Yaseen Khan, the bearer, clad in snow-white tunic
and dhootie, and having on his head a voluminous turban—how he
had set himself in order no one ever knew—steps forward, and
having, with his usual dignity, saluted those in the tent, ushers in the
doctor.
Then from that irrepressible little person in the corner there comes a
peal of laughter. 'Bravo, Yaseen Khan!' she cries. 'You are decidedly
master of the situation. Have you been hiding yourself in a band-box
all this time, you most unconscionable old man?'
Yaseen Khan merely salaams and smiles. He is busy attending to his
master, and has no time for banter.
CHAPTER XXII
THE RAJAH SURPRISED
It was on that very night, the night of the 23rd of May, that
Hoosanee returned to Gumilcund, after his unsuccessful effort to
save Grace Elton and her cousin. He reported himself to his master
at once, and gave an account of what he had done. It was his
opinion that the rising at Nowgong would be speedy and cruel. Many
of the Sahibs, he said, were disliked by the people and soldiers, and
would not be spared. He did not venture to repeat his conversation
with the chuprassie; but he said that he believed there was one
servant in the Captain Sahib's service who might be trusted. 'The
lotus-eyed,' he averred, must be saved at all hazards, and he
offered, should his master desire it, to go to the station again, and
to linger about in disguise, watching over her, until the danger was
over, or the rising had come. In case of a rising, he would provide
for some temporary refuge in the neighbourhood, whence, if they
could not escape in any other way, his master would fetch them at
the point of the sword.
Tom agreed to the proposal, suggesting only that he should go in
place of Hoosanee; or, if that were impossible, that they should go
together. But both his servant and Chunder Singh, who was present,
pointed out to him so clearly that his presence, instead of helping,
might spoil everything, that he was obliged to give way. Hoosanee
should have the honour and joy of watching over the sweetest
woman on all the earth; Chunder Singh should hold himself in
readiness to obey the first summons to arms, and Tom had spies
posted in the different villages on the route between Nowgong and
Gumilcund, so that Hoosanee's messages might be passed on from
one to another, and that help could reach him speedily.
He was himself meditating a dangerous enterprise, nothing less than
marching into Jhansi alone, presenting himself before the Ranee,
and persuading her, under promise of his personal support, and his
influence with the Government in case of her failure—for he had
now certain knowledge that she intended soon to raise the standard
of revolt—to allow him to carry off to Gumilcund the English women
and children in the station.
But many things had to be done before he could start. June was
nearly in when, riding Snow-queen, and dressed as an Indian of
rank, he left Gumilcund. In despite of all Chunder Singh urged to the
contrary, he was unattended, it being his belief that the Ranee would
be more likely to listen to him if he entered her palace alone.
The hot season being well in, he travelled principally at night, resting
by day in a grove or peasant's hut. He was treated with
consideration everywhere. Now and then a greybeard would reprove
him for travelling so heedlessly in these unsettled times, and once or
twice he was asked his business. To this he would answer that he
was a kinsman of the Ranee of Jhansi, and that she had sent for
him; but that what her will was he knew not. Everything, in fact,
went well, so that, but for the adventure I am about to relate, he
would have been in Jhansi before the rising; and it is just possible
that, by his influence, the memory of a proud and not ungenerous
woman would have been saved from a foul blot, and many innocent
people delivered from destruction.
He came to within a few miles of the borders of Jhansi. For the last
two days he had been pressing his pace, for sinister rumours were
abroad, and he feared to be too late. But there had been terrible
rain, and the ways were miry, and Snow-queen was hanging her
head dejectedly. For her sake rather than his own he determined to
rest for a few hours. There was a village close by. He rode in slowly,
and asked for the house of the headman, where, after a little parley,
he was allowed to rest, while he watched his horse being fed and
watered.
He was on the little mud platform in front of the house. Snow-queen
was tethered close by. It was mid-day and the place was silent as
the grave, so that presently, in spite of strenuous efforts to hold his
eyes open, he fell into a dog's sleep. How long it lasted he could not
tell. He was aroused by the trampling of feet and clamour of many
voices. He sprang up, and, almost at the same moment, the
headman came to him, with a strange look in his eyes.
'You must go on,' he said, 'the Ranee is here.'
'Ranee—what ranee—of Jhansi?' he asked.
'I know not,' the man answered; 'but we want this place.'
'And you shall have it. I am ready to go on,' answered Tom. 'First let
me pay you for your trouble.'
The man took the money hurriedly, and Tom turned aside to where
he had left Snow-queen, and vaulted into the saddle. He had
scarcely done so before the foremost of the troop of horsemen that
were clattering through the village came up with him and seized his
bridle-rein.
'What do you want with me?' said Tom, trying to free himself.
In a trice two or three more rode up, and he found himself
surrounded.
'Now, then,' he cried out, angrily. 'What is the meaning of this?'
'Our lady, the Ranee, would have speech with you, sir stranger,' said
the first of the troop.
'Where is she; and what does she mean by stopping a peaceful
traveller?'
'You are alone. She has armed men at her back,' said the horseman
cynically. 'But she means you no hurt. You had better come quietly.'
'Loose my bridle-rein, then,' cried the young rajah. 'And you,' to the
two or three ragged-looking figures that were crowding about him,
'fall back!'
They obeyed and he went forward slowly, with all the dignity he
could command. Had he seen any chance of escape, he would have
given a touch to Snow-queen, and in a few moments she would
have shown them a clean pair of heels. But he was not in open
ground; he was in the long straggling street of the village, with
horsemen in front of him and horsemen behind, and there was no
possibility of getting away. Wit, he felt, must serve him for strength,
and if, as these men had said, their leader was really a woman, he
did not doubt that he would be able so far to humour her as to be
allowed to proceed.
Presently he lifted up his eyes and saw her. She was in the midst of
the cavalcade, borne in an open palanquin, and covered from head
to foot in a saree of black gauze richly spangled with gold.
As he approached, the men-at-arms who accompanied her
separating to right and left to let him pass, she ordered her bearers
to stop. Tom drew up in front of her and made a low salute. He
could not discern the features of the lady's face; but he saw enough
to make him sure that she was not the Ranee of Jhansi. A few
seconds passed. He would not speak until she addressed him; he sat
with head bowed humbly, after the Oriental fashion, while the
piercing eyes behind the black and gold saree looked him through
and through.
Then came a curious and unexpected shock. She was speaking. He
thought, at least, that she was speaking; but he could not be quite
sure that his senses had not deceived him. For this high, clear voice,
winged, to his fancy, with mockery, was not, certainly, the voice of
one of the daughters of the land. Yet the language was the supple
Urdu that the educated natives use.
'Who are you, sir stranger? And what brings you to our dominions?'
she said.
He gave an involuntary start, then answered, bowing low, 'Were it
not that the whole world is under the dominion of beauty, I might
ask my gracious lady her right to stop the traveller on his journey. As
it is, I bow to her will. I am a kinsman of the Ranee of Jhansi, and I
go in hot haste to confer with her on the strange portents of the
time.'
From behind the saree came a sound like the repressed gurgle of
laughter; but it was stopped instantly, and the high, disdainful voice
went on. 'I believe that you are lying, sir stranger; but the truth of
your saying shall be proved. We, too, propose to visit our sister of
Jhansi. Remain you with our escort, and we will take you in with us.
If you are really what you profess to be, the delay will be of no
account to you, and you may save your skin.'
'My skin is not of so much account to me that, for its sake, I should
neglect my duty. The business on which I have come is urgent, and I
cannot delay. Will your Highness permit me to take my leave?'
There was another suppressed gurgle. He could have sworn,
moreover, that from under the black and gold gauze there came a
little English 'No'; but in the next moment he thought that his fancy
must have been playing tricks with him, for the veiled lady was
speaking in stern, slow accents.
'I will not permit you to leave us. Fall back, and take your place
amongst my men.'
'Your Highness——'
'Silence! I have listened to you long enough. Abdul, seize his bridle-
rein. If he resists, dismount him, and bring him on foot.'
Seeing that there was, for the moment, no possibility of successful
resistance, Tom fell back amongst the escort, who, so long as he
walked on with them quietly, did not seem disposed to show him any
violence.
The headman of the village came out, meanwhile, to meet them,
bringing provisions, and laying himself and all he possessed at the
feet of the Ranee. She accepted his homage, but did not deign to
speak to him, and, after halting for a few moments, she ordered her
bearers and escort to proceed.
Tom had been longing to leave the village, for he thought that, on
the open ground, he might easily escape; but he found himself so
closely watched, that no such effort was practicable. Reluctantly he
made up his mind to wait until the night.
He had gone over this ground before, making himself well
acquainted with the bearings of the country, and when, soon after
leaving the village, the leaders of the cavalcade swung round to the
left, he knew perfectly well that they were going away from Jhansi,
and not towards it. This he said to Abdul, but he was vouchsafed no
answer. Tired and irritated, wondering what was to be the end of
this strange adventure, and blaming himself bitterly for having
halted when he was almost within a stone's throw of his goal, he
went on the way he was led.
It was afternoon when the veiled lady met him, and they tramped
on until nightfall.
By this time, so far as Tom, who had begun to lose his bearings,
could judge, they were many miles distant from Jhansi. They
encamped in open ground, there being no village or grove of trees
at hand. A tent was pitched for the lady, who had been travelling for
some time with the curtains of her palanquin closed. Tom, who felt
that she was dealing treacherously with him, and who was haunted,
moreover, by a bewildering suspicion that she was something very
different from what she gave herself out to be, made an effort,
when the cavalcade halted, to spring forward from his place in the
rear, that he might speak to her, or at least catch a glimpse of her
figure; but the fierce and burly Abdul placed himself in front of him.
The vigilance of this man had never for one moment faltered, and it
was evident to Tom that he was keeping up the other men to their
duty of watchfulness.
Thinking it well to appear submissive, he dismounted with the rest of
the horsemen, tethered and fed Snow-queen, and joined one of the
groups that were assembled round the little fires that had been
lighted to cook the men's evening meal. A place was made for him,
and he was given a supper of chupatties and dal, which, as he was
simulating the manners of a person of high rank, he received in his
own bowl, retiring a few yards distant from his attendants to eat it.
Then he returned to the spot where he had left Snow-queen,
wrapped himself up in his chuddah, and, with his back propped
against the tree to which she was tethered, fell into a deep sleep.
Tom was one of those favoured mortals who have the gift of sleep.
No matter how anxious and harassed he might have been in the
daytime, night always brought him peace and refreshment.
Afterwards he thought of it as a strange thing. Here he was alone in
the midst of strangers. What they wanted with him he did not know;
but he knew full well that he had upon his person what, if they
discovered it, would tempt their cupidity past any reasonable limit of
endurance; he knew also that he had a great stake to fight for, and a
hard problem to solve, and yet he slept—slept as peacefully as if he
had been in his own little room in the cottage that looked down
upon the silver Thames.
Two hours passed away. His attendants had looked at him several
times, and, at last, being satisfied of his perfect unconsciousness,
they had followed his example, and now no one but Abdul was
awake.
Abdul had received his orders. He was to watch over the prisoner,
but not to molest him in any way; he knew very well that, if he were
detected in any attempt at outrage or robbery, he would pay the
forfeit of his life for the crime; but the stillness of the moment and
the perfect unconsciousness of the sleeping man were too much for
his prudence. He would not hurt him. That would be to betray
himself; but he would cautiously feel about him to see if he had
valuables concealed in his sash or turban. If he had not, no harm
was done. If he had, and if Abdul purloined them, then Abdul would
be so much the richer, and the high-born youth, who would not
venture, surrounded as he was by hostile strangers, to make any
ado about his loss, would be the poorer. And that would be all.
Thinking thus he crept closer to Tom, and, having softly drawn his
chuddah aside began to finger his fine satin tunic. Once or twice the
sleeping youth stirred, and then the robber drew back, but
supposing himself in a dream, he settled down again, and Abdul
went on with his work. The heart of the robber was jubilant and his
fingers were light, for he was sure now that there was gold in the
youth's waistband, gold which would soon be transferred to his own.
The gold was almost within his grasp, he heard its jingle, his long
fingers swept it, as they moved to and fro. Why then did he stop
suddenly and draw back? Had he seen the youth's breast and
shoulders white in the moonlight, and did he recognise him as one
of the hated race, whom, in a few short weeks, the children of the
Prophet would scatter and slay? But this should have given him
courage, for he knew very well that he had but to say that a
Feringhee spy had entered the camp, and the youth whom he
purposed to rob would have his lips sealed effectually. Surely it was
something more that stayed Abdul's hand. And, in that moment's
pause, his prey escaped him. Strong, and with all his wits about him,
Tom awoke; seeing his chuddah and tunic open, and Abdul glaring
at him, like a startled wild animal, he sprang to his feet and struck
out with the dagger which he carried in his belt.
At the same moment the robber was smitten from behind. As, with a
muttered cry, he fell to the ground, a voice broke upon the stillness
of the camp: 'So the White Ranee punishes treachery. Let all take
notice and beware!'
CHAPTER XXIII
THE SNAKE-CHARMER AND THE VEILED LADY
As for Tom, he laid himself down again, not to sleep this time, but to
watch. There was, however, no further alarm, nor, when, long before
dawn, the camp began to stir and the morning fires were lighted,
was any remark made with regard to the incident of the night. A
narrow trench was dug; the robber was laid in it, and, once more,
the cavalcade moved forward. Throughout that day they went on
steadily. The prisoner was continually on the alert, but he was given
no chance either of escaping or of speaking to the veiled lady in the
litter. His passionate irritation over the delay grew, meanwhile, to
such a height, that he was on the point once or twice of making
some mad effort that would have had the effect of either seriously
jeopardising his life or putting fetters on his limbs. That he
restrained himself was due not so much to prudence as to fatality.
He could never find a moment when his will-power and his
surroundings leapt together. When he might have acted he could
not. When all his nerves were braced and the blood coursed like fire
about his heart, something would always happen to make action
impossible. So, with throbbing brain and a heart as heavy as lead,
he travelled on. Every hour was taking them further away from
Jhansi, and nearer Gumilcund, although they were not shaping their
course directly for the last-named city. The men were reticent before
him, but he gathered from a stray word here and there that they
were themselves uncertain about their movements, which would
depend upon the result of an enterprise undertaken by some of their
comrades.
Towards mid-day they halted, and a man, who appeared to be a
moulvie, or priest, joined them, was admitted to the tent, and held a
conference with the lady, travelling on with the cavalcade as far as
the next village, where he took his leave. What news he brought
Tom did not hear, but he judged from the jubilant faces of the men,
and the laughter and rude jests, some of which made his blood
curdle, that there had been another triumph over the Europeans,
and that these men were expecting to share in its results.
Evening came and they halted again. It was in the neighbourhood of
a large village, to the right of which stretched a mere or shallow
pond, half covered with red pond-weed and overshadowed with
some fine acacia and fig trees. By order of the lady in the litter, her
tent, which always formed the centre of the camp, was pitched on
the shores of the mere, being separated from the village by its
waters.
Immediately the men unsaddled, tethered and fed their horses, and
lighted their evening fires. The villagers, meanwhile, who were
hiding behind every tree and angle of wall, having satisfied
themselves that those in camp had no hostile intentions, poled
themselves over the mere in flat-bottomed boats, bringing with them
fruit and vegetables, and grain and milk, so that presently the camp
was like a fair.
Sitting by the mere, and listening absently to the jabber and turmoil
of the camp, where buying and selling and wrangling and gossiping
were going briskly forward, Tom watched the curious scene. He was
trying to devise some scheme either of escape or of making his
situation known to Chunder Singh, when, suddenly, and in obedience
to no act of volition of his own, so at least it seemed to himself, the
current of his thought changed. It darted upon him with the force of
an electric current that the scene upon which he was gazing was not
new. The livid sky behind the mud walls of the village, the blood-red
pavement at his feet, the fierce dark faces about him, surely, in
some other life, he had seen them before. A moment more, and he
remembered. He was living again over the strange night when all
the conditions of his life were changed; his feet trod the banks of
the stream that washed the gardens of his tranquil home; the dawn,
the sweet dawn of an English June, was breaking, and the trees that
he knew and loved were swaying to and fro over his head to the
delicious breeze of the morning. Then he had seen this! It was his
dream, his very dream; but not all!
The effect upon his mind was overpowering. His strength, and the
presence of mind, upon which he had always relied, seemed to be
oozing away. Fate! Fate! and no hand of man was fighting against
him! What could he do but submit? Shuddering, he covered his face
with his hands. He must hide it away. He must forget. He must clear
his mind from the stupefaction that was stealing over it, or all would
be lost. But it was in vain, for, with his every effort, he seemed only
to sink more deeply into despondency and bewilderment.
Suddenly a sound came to him. It was as vivid to his sense as is the
light of morning to the belated traveller—a voice clear and strong.
'Why,' it said, 'should this thing startle you? If a vision was granted
to you, if you saw, beforehand, what would be in the future, and if
now the vision is followed by what is, or appears to be, a reality, is
that any reason why your strength and presence of mind should
desert you?' A pause, and then, answering the thought of his heart,
the voice went on, 'Fate! That is true. Everything is fate. But our
resistances are predicted and foreseen as well as our trials. Arise
and be of good cheer. This is no omen of evil, but rather of good.
You say that the vision is not over. Again you are right. There is
more to come, and in due time and place you will behold it; but tie
not your limbs from present use in consideration of that which they
may have to do in the future. In coming hither you have chosen
rightly. She, like you, must "dree her dread"; but the Holy Ones love
her, and will have her in Their keeping. Listen!'
At this moment—it seemed a strange and incongruous thing—there
broke in upon the eager spiritual colloquy a sound so ridiculously
common and familiar that, uneasy as he was, Tom could almost
have laughed. It was the discordant rattle with which, in India, a
snake-charmer and conjuror calls his audience together. The sounds
came from behind Tom. Turning in haste, he saw a hooded snake
rearing up its ugly neck and head within a few feet of him. Behind
the snake, sitting crouched together and eyeing him curiously, was
an old man, with coal-black face, white hair, and supernaturally
bright eyes. He was wrapped in a dirty white chuddah; a cloth,
containing his implements of trade, lay outspread before him, and he
held in his hand a light wand, with which he was directing the
movements of the snake.
When Tom turned he stopped his jabber for a moment to beg him
not to be afraid, adding impressively that if he would only have
patience, he would behold such a sight as he had never seen before.
'Others kill,' cried the old man, looking round on the soldiers who,
pleased at any sort of fun, were crouching about him. 'They bring
you a mongoose. There is a fight. The monster is killed. He lies stiff
and stark before you. You clap your hands like silly children. But
what is that? Nothing. I snap my fingers at them. No mongoose
here, good sirs! No killing! I did not say no fight. Yes, you love
fighting, and a fight you shall see! But a man will fight the monster;
a man with his naked hands, and it shall be—not killed—but tamed!
That is the true triumph, my masters—the true revenge! My enemy's
blood, what is it? For a moment it fills my nostrils with its savour, in
the next it is gone. But to tame him, to see him lie down at my feet
and lick my hand, to spurn him once, and yet again; day after day to
behold him grovel more deeply before me. This is joy! This is
ecstasy! And it is this, in little, which I call you to behold.'
He spoke in a high key, and with the most extraordinary rapidity,
holding his wand, as he spoke, over the head of the cobra, which
moved uneasily from side to side as if it were trying to escape from
some fascinating influence. His voice dropped and there was a lull.
The serpent gazed at him sleepily. He crooned a low song, which
seemed to have a stupefying effect upon it, for it dropped and lay
like dead. The soldiers, meantime, stirred to the entrails by his
address, showed all the symptoms of intoxication; some rolling
about in speechless ecstasy, others dancing, singing, and shouting,
so that, in a few moments, the camp was changed into a field of
demons.
There came a cry from the snake-charmer. 'Give me room—room!'
and, in the next instant, he had flung his wand aside, thrown off his
chuddah, and leapt to his feet. At the same moment the serpent
reared itself up, shot out its forked tongue, and threw its sinuous
body at the man, who received it on his knotted arms. The hideous
combat went on for some minutes. Now the man seemed to triumph
and now the serpent. Tom was sick with loathing; but he could not
turn away. An invincible fascination, helped by a suspicion that the
combat had some mysterious importance for himself, kept his eyes
fixed.
Suddenly the silence of the camp was broken. There came a cry of,
'Give place! The Ranee is coming!'
The combat was at its height—the man almost lost in the folds of
the cobra, and the awe-stricken circle falling back—when Tom, who
had kept his position near the snake-charmer, saw her come out.
She was dressed in the brilliant robe of black and gold in which he
had seen her first, and covered from head to foot, so that he could
not see her face. With slow and dignified step she advanced towards
them. She had crossed half the space that separated her from the
snake. It had loosened itself from the man, and was turning in this
new direction. Unable to restrain himself, Tom darted forward. 'Keep
back!' he cried in English. 'You are mad!'
She spread out her arms, waved him back imperiously, and moved
forward. At the same moment Tom saw on the face of the snake-
charmer a look of such anguish and dismay that he thought his
enemy had conquered and given him a deadly wound. Yet the snake
had dropped and was lying at his feet, not dead, but spent.
Confused and troubled, Tom fell back. The lady was advancing still.
She was within a few feet of the snake. Its master warned her back,
but she took no heed of him. Then Tom, who could bear it no longer,
turned away and covered his face with his hands. There was a
moment of absolute silence. His heart beat with curious rapidity,
there was a singing in his ears that almost deprived him of the
power of hearing, and though feeling that this would be the time to
get away, he seemed to lack the power to move a step. All at once
there was a shout. It was followed by another, and then by another,
'Victory! victory! Our Ranee-jee, daughter of the Prophet, protected
of Allah, has triumphed!' The cries rang through the camp, were
taken up by those who clustered round it, and echoed back from the
village, so that in a moment all the country seemed alive.
At the sounds Tom turned, and this was the strange sight he saw. In
the centre of the vast circle and at some little distance from the
snake-charmer, who, recognising probably a master in his craft, had
drawn back, and was now close at Tom's elbow, stood the Ranee.
She stood with her head proudly raised, so that she looked taller
than before. One little foot was planted firmly on the ground, the
other rested on the neck of the cobra, which cowered before her as
if smitten with sudden fear. But the strangest part of all was that the
black and gold saree had been thrown back and that her face was
exposed. With parted lips Tom gazed. It was the face of a little child,
soft and white, with rose-red lips, and smiling eyes, in which the
golden light of summer dawns seemed to be sleeping, and—if he
was not mad—if he was not dreaming—he had seen it before.
CHAPTER XXIV
SUBDUL
Tom's first idea was that she, like himself, was a prisoner, and he
was about to commit the terrible imprudence of flinging himself at
her feet, and begging her to accept his protection, when the snake-
charmer passing him by, brushed him as if by accident, and pausing,
made a low salaam, and breathed an apology. There was a look in
his face which arrested Tom's attention; under cover of the clamour
which had not ceased, he said in a low voice and in Marathi, which
was known to his spies, 'Are you a friend?'
'I am his Highness's servant,' said the man, 'and I will help him to
escape; but he must be prudent. The White Ranee is black of heart.'
As he muttered the last words, speaking them in so low a tone that
no one but Tom could hear, he was moving towards the Ranee. She
greeted him with a smile of childlike triumph, and he prostrated
himself at her feet. Then, resuming his wand, and singing his
lullaby-song, he enticed the monster into its basket, while the
Ranee, having looked round her proudly, threw the black and gold
saree about her head, and returned to the tent. The snake-charmer
began now to circulate among the soldiers. He was full of stories
and jests, and wherever he went he was received with acclamations.
Tom, who had taken up his station under the tree to which Snow-
queen was tethered, watched him moving to and fro. Presently he
noticed a strange thing. It was only as long as the snake-charmer
was in the midst of each little group that its members were joyous or
lively. As soon as he left them they became silent, most of them
falling shortly into a heavy sleep. This must have been apparent to
others besides himself, yet there were none who did not watch for
and expect his coming. Night had fallen before he had made his
round of the camp, and then all, with the exception of two sentinels
outside the tent, were in a deep slumber. He crept now to the
neighbourhood of Tom's station, and professed to curl himself up for
sleep. The sentinels watched him drowsily. After a few minutes of
perfect silence, one of them sat down and leaned his back against a
tree. His comrade followed his example. They exchanged a few
remarks to keep themselves awake. One drank from a bottle in his
girdle and offered it to the other, whereupon their dropping remarks
fell off into silence. And now no one in all the camp was awake but
Tom and the snake-charmer.
It was nearing midnight, but the moon—which was on the wane, but
which in this clear atmosphere diffuses a brilliant light—enabled
them to see their way, and they both arose.
'Now is our time,' said the snake-charmer, chuckling. He was none
other than Subdul, Snow-queen's groom.
'Are you sure they are well settled?' said his master.
'I have given them bhang, Highness. That, and the excitement of the
evening, will make them sleep like the dead; no noise will awake
them. But the nights are short; why does my master linger?'
'Are you sure she is not a prisoner, Subdul? Might she not come with
us if we told her our design?'
'If my master means the Ranee, I tell him that she is black—black at
heart and false of speech. Let not my master trust her.'
'What do you know of her, Subdul?'
'I know what these have told me. Does my lord know Dost Ali Khan?'
'The adopted son of the rajah of that name?' cried Tom, with some
excitement; 'why, I entertained him once. I have now a pass from
him about me. Has he anything to do in this?'
'He has everything to do. He is the hope of thousands. They crowd
round him as their lord. If my master has won Dost Ali Khan's favour
he is lucky. This man, my lord, this so-called prince, has, as I hear,
persuaded the White Ranee to join herself to him. She was married
to an English sahib, and she saw him slain. She looked on at the
slaughter of her countrymen and women, and now, in her new lord's
name, she is taking command of the murderers. If my master wants
any more proof that she is a traitress——'
'Silence, Subdul! She is coming!'
'Master! master!' cried the man in strong excitement, 'now is the
time to fly!'
'I must let her speak to me first.'
'No, no; let my master listen to me! She is a witch; she will enslave
him.'
'Nonsense, Subdul; I know her, I tell you. Be silent!' murmured Tom,
whose heart was beating strangely.
And all this time the White Ranee, with veil thrown back, and face
looking pure and spiritual in the moonlight, was making her way
quietly through the sleepers of the camp towards the spot where
Tom was standing. They were alone now, Subdul having
disappeared. Tom did not move, for a spell seemed to be over him;
so she went close to him and laid her hand on his arm. Then a
sudden trembling seized him.
'Who are you?' he said, in a low voice.
'Surely you know me,' she answered. 'I know you, Tom Gregory.
Why did you run away from Delhi without seeing me again?'
'Why are you here?' he said sternly.
'You are impolite, my dear boy. A question should be answered.'
'This is no time or place for amenities, and you know it. Answer me!
Are you a prisoner? For if so I will take you away with me and
protect you honourably until I can restore you to your own people. If
you are not a prisoner—if you have given yourself up to the enemies
of your race, then I will leave you to reap your own punishment.'
The lady laughed. 'So stern all of a sudden!' she said.
'You are playing with me. You are wasting time.'
'Time was made for slaves, Tom,' said the lady, in a sweet girlish
treble, 'and I am not a slave; neither are you. Sit down under this
tree, and let us talk together quietly. Ah! how pleasant it is to speak
to an Englishman again!'
'Vivien! are you mad?'
'Yes, I am mad, always mad, Tom; but madder than ever now. Be
mad with me; you have no idea how delightful it is to live in a
dream!'
'The dream will soon be over, my poor child. Do you think that you
can tame men as you tame serpents?'
'Think? I am sure of it, Tom!'
'Then, if this is your dream, for heaven's sake awake! Good God!
why do you look at me so?' cried the young fellow, in a sudden
transport.
She was standing before him in the moonlight, her golden hair
blown this way and that way with the wind, her eyes full of laughter,
an expression half-mocking, half-pitiful, playing about her lips.
'Do you know how awful this time is?' he said. 'Are you human?'
She laughed. 'No,' she said, 'I don't think I am. Take my advice,
Tom, and be inhuman too!'
'Vivien, you are playing with me!'
'Of course I am; I never do anything but play. I played with you, and
if it had not been for Grace Elton, who is a very serious young
person, I should have won you over as a playfellow. I played with
Charlie Doncaster, poor boy! But he had not my animal spirits, and
he was beginning to be grave and tiresome when—but I don't want
to talk of disagreeable things. Well! The next was his Royal or
Imperial Highness, Dost Ali Khan. I wonder, by the bye, if you
remember him. I was within an ace of running over him in the
streets of Delhi. It would have been a good thing for some people if
I had succeeded. You saved him, didn't you? Set that as a make-
weight against all your good deeds, Mr. Tom, and see what the result
will be! But to return, as the story-tellers say. I was so much amused
with his Highness that I took the trouble to cultivate him; and it was
a very funny little episode, I can assure you. Heavens! how he hated
me at first! I tell him sometimes that I am surprised he did not kill
me, for I gave him heaps and heaps of chances. He let me live,
however, against his better judgment, I believe, and now he is my
slave. I can do whatever I like with him. What do you say to that for
a game?'
'I say that you are mad—that you don't know what you are saying,
and the night is passing. No more of this folly! Will you come with
me or will you not?'
'Tom, what a baby you are! Never mind, I like you so! But be a wise
baby if you can, and listen to me quietly. I am not going with you. It
would be absurd to begin with, and highly dangerous, all through.
On the other hand, having found you, I don't mean to let you slip
out of my fingers. So you must come with me. I must tell you that
you have been so fortunate as to make Dost Ali Khan, his Imperial
Highness of the future, your friend. He is the great man just now, for
he is the only person in this part of the world who knows what he
wants, so the rest of them look up to him. The soldiers, banded and
disbanded, the native states, the fanatics of the towns, they are all
waiting for his signal. When he gives it—Heavens! I begin to feel
sane, as I think of it—what a conflagration there will be! However,
that is beside the present question'—she stopped to laugh. 'I think I
am speaking rather weightily,' she said; 'don't you? Now, to go on in
the same strain, this exalted personage, whose ally I am, offers you
his friendship. He doesn't wish you to fight for or with him, for he
believes you would say "No," and he has a sort of conscience about
destroying you. What he asks is that you will take me into
Gumilcund—think of the magnanimity of it!—and keep me there until
the explosion is over. Then, if the world doesn't meanwhile fall in
ruins about us, we can decide about the future.'
She paused and went a little closer to him. A cloud had veiled the
face of the moon so that, near as she was, he could only see her
indistinctly; but he felt her—felt her in every nerve of his being, and
for a moment he hesitated. Why should he not, after all, take her
back to Gumilcund first, and leave her there in safety before setting
forth on any other mission of rescue? He did not believe all she had
told him. Either she was mad—as she said of herself—and in that
case she ought to be protected from the results of her own mad
actions; or else she was playing with him. Yes, she had herself
spoken the word. But was she accountable for her own strange
nature? Should she be punished because she could not see the awful
realities that lay about her? Since, by some strange freak of fortune,
she had been able so far to gain protection, was he to deny her the
asylum that would make her safety sure?
While he reasoned with himself she stood by him. She did not speak,
she did not stir; but as the silence prolonged itself a sigh, soft as the
breath of a sleeping child, escaped her lips.
'Vivien!' he said tremulously, 'is that you?'
'Yes, it is I; I am near you. You will come with me, Tom?' she
murmured; and, in low caressing tones, 'Dearest Tom!'
'Why do you say that?' he said, hoarsely.
'Listen to him, poor child!' she cried. 'Why? Can't you tell? Can't you
imagine?'
'You are false!' he groaned; 'you have said it of yourself!'
'False to others, Tom; never to you!'
'False to one is false to all.'
'Listen to him!' she cried again. 'What an exalted standard! But, my
young king, let me tell you that you are ungrateful and unjust. If I
could only save you by being false to others; if every subterfuge,
from the beginning, was planned for this—that I might have you;
that I might hold your life in my hands—what then?'
'Is it so?' he said hoarsely.
'You see!' she cried; 'you were cold because you did not understand!'
At this moment, when his will was passing away from him, and his
heart was as wax in the midst of his body, there came a strange and
sudden disturbance. Subdul Khan had been crouching behind them;
his ear was to the ground, and all his senses were on the alert, for
he feared treachery. Whether he did actually hear in the distance the
rumble of gun-carriages and the sound of armed men on the march,
or whether he merely professed to hear them to arouse his master,
cannot be certainly known; but the effect was the same. Suddenly,
with a cry of, 'The rebels are upon us!' he sprang to his feet.
Snow-queen was saddled, and so was the horse of Subdul Khan.
They mounted them together, and while Vivien, with a ringing cry, to
which none of the besotted men about her paid any heed, ran
frantically through the camp, Snow-queen and her master, going like
the wind, disappeared in the distance.
CHAPTER XXV
AN AWFUL RIDE AND A RESCUE
Hurry on, brave men! let the wind be your messenger; stop neither
to eat nor drink; through the long sultry day and at nightfall, when
the awful eye of day is closed and the stars come out pale and
languid overhead, even until morning dawns and the terrible round
of sweltering heat and blinding dust begins again—hurry on! By
narrow and unfrequented ways, through villages whose favour has
been bought, under the shade of trees, and across tracts of jungle,
where you are obliged to go at a foot-pace, giving breathing time to
the gallant beasts that have carried you so bravely—on and ever on,
for two dreadful days and nights, that to one of you seem ever
afterwards like an awful dream. And yet, you are too late. And well it
may be for yourselves that you did not arrive earlier. For the storm
has broken. In fire, and blood, and fever it is spreading from city to
city, and Jhansi, the home and citadel of a woman scorned, has
caught the dread contagion.
Up to June 1 they were at peace. The Ranee still sat smiling in her
palace, and still she added to her body-guard persons of proved
loyalty, and still the English believed her promises, and still the
troops within the city proclaimed their faithfulness loudly. And why
did the English need to fear? Meerut had not moved them. Delhi had
not moved them. The native states, Gwalior and Gumilcund, and
Rewah and Banda, were holding their hands. Nay, it was known that
some of them had offered help to the Paramount Power in the re-
establishment of order; and even if they had feared, what could they
do? To show mistrust at this eleventh hour would be to undo all that
had gone before, and to ruin everything.
On June 3 mysterious fires broke out; but even these did not unduly
alarm them. They were attributed to accident. It was not until the
4th that their eyes were opened. Then the soldiers on parade,
breaking away suddenly and causelessly as it appeared to those who
had not heard of the secret messages that had been passing
between the palace and the native lines, shot down their sergeant
and seized the artillery, and with it made their way to the fort within
the native city.
The Ranee still sat smiling in her palace; but when the news came to
her she ordered the palace gates to be opened, mounted her horse
and cantered over to the lines with her own faithful body-guard, who
in her name had seized upon the treasury, behind her.
Some of the English officers had been hurrying to her palace. They
were told on the way that she was in the hands of the mutineers,
and instantly the full magnitude of what had happened darted upon
them. They dashed back to the cantonments, calling as they went
on the English and Eurasians to follow them into the Star Fort, the
only building belonging to them now that was capable of defence. It
all happened in a moment. Some of them had not even heard of the
disturbance on parade. In the little house, once a tomb on the
maidan, something had been seen; but no one clearly understood
what had happened. 'Father will be in presently, and then we shall
hear,' said Mrs. White to her little Aglaia, as she tried to soothe her
off to sleep. But then the ayah rushed in like a wild creature, and
with a cry of 'They are coming; hide!' tore the child out of her arms.
She knew little more. Some one came and dragged her out of the
house, and she was mounted on a horse, to which, crying out for
her child, she clung because she could not help herself, and there
was a mad, sick flight across the blaze of the maidan, with yells at
her heels, which seemed to recede as she flew on, and then all at
once she was in the Fort amongst a circle of frightened women, and
her husband, who had not come for her himself, having work to do,
was with the men, but her child—her little darling—was nowhere to
be seen. She made a wild rush for the door. Even amongst the
rebels there must be some one who would have mercy upon her.
When they held her back by force her shrieks and cries were piteous
to hear.
But all were not so helpless. In the little spell of time given them by
the rebels who were quarrelling over the booty, the men looked up

More Related Content

PDF
Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition Anth...
PDF
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
PDF
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
PDF
Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition Anth...
PDF
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
PDF
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
PDF
Practical Sql A Beginners Guide To Storytelling With Data 2nd Edition 2 Conve...
PDF
(Ebook) The Rust Programming Language, Second Edition by Steve Klabnik, Carol...
Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition Anth...
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition Anth...
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
Practical Sql A Beginners Guide To Storytelling With Data 2nd Edition 2 Conve...
(Ebook) The Rust Programming Language, Second Edition by Steve Klabnik, Carol...

Similar to Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthony Debarros (20)

PDF
The Rust Programming Language Steve Klabnik
PDF
Mastering Qlikview 1st Edition Stephen Redmond
DOC
Sap bo 4.2 course content (1)
PPTX
ITT PROJECT IN EXCEL AND WORD
PDF
Front End Ui with React online training | Front End Ui with React training | ...
PDF
Sql a practical introduction
PDF
Sql a practical introduction
DOC
SAP BO Dashboard Training Online
DOC
SAP BO 4.1 Training
PDF
Download Complete The Rust Programming Language 2nd Edition Steve Klabnik PDF...
DOCX
Cis336 week 5 i lab5
DOCX
Cis336 week 5 i lab5
DOCX
Cis336 week 5 i lab5
DOCX
Cis336 week 5 i lab5
DOCX
Cis336 week 5 i lab5
DOCX
Cis336 week 5 i lab5
PDF
MIS5101 WK10 Outcome Measures
DOC
Sap bo 4.2 course content
DOC
SAP Business Objects 4.2 Training Online
The Rust Programming Language Steve Klabnik
Mastering Qlikview 1st Edition Stephen Redmond
Sap bo 4.2 course content (1)
ITT PROJECT IN EXCEL AND WORD
Front End Ui with React online training | Front End Ui with React training | ...
Sql a practical introduction
Sql a practical introduction
SAP BO Dashboard Training Online
SAP BO 4.1 Training
Download Complete The Rust Programming Language 2nd Edition Steve Klabnik PDF...
Cis336 week 5 i lab5
Cis336 week 5 i lab5
Cis336 week 5 i lab5
Cis336 week 5 i lab5
Cis336 week 5 i lab5
Cis336 week 5 i lab5
MIS5101 WK10 Outcome Measures
Sap bo 4.2 course content
SAP Business Objects 4.2 Training Online
Ad

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Final Presentation General Medicine 03-08-2024.pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
VCE English Exam - Section C Student Revision Booklet
Chinmaya Tiranga quiz Grand Finale.pdf
Computing-Curriculum for Schools in Ghana
STATICS OF THE RIGID BODIES Hibbelers.pdf
Complications of Minimal Access Surgery at WLH
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Final Presentation General Medicine 03-08-2024.pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
2.FourierTransform-ShortQuestionswithAnswers.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Classroom Observation Tools for Teachers
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Orientation - ARALprogram of Deped to the Parents.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
O7-L3 Supply Chain Operations - ICLT Program
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Ad

Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthony Debarros

  • 1. Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.com Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthony Debarros https://ebookmeta.com/product/practical-sql-a-beginner-s- guide-to-storytelling-with-data-2nd-edition-anthony- debarros-2/ OR CLICK HERE DOWLOAD EBOOK Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com
  • 2. Recommended digital products (PDF, EPUB, MOBI) that you can download immediately if you are interested. Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthony Debarros https://ebookmeta.com/product/practical-sql-a-beginner-s-guide-to- storytelling-with-data-2nd-edition-anthony-debarros/ ebookmeta.com Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition Anthony Debarros https://ebookmeta.com/product/practical-sql-a-beginners-guide-to- storytelling-with-data-2nd-edition-anthony-debarros/ ebookmeta.com SQL QuickStart Guide The Simplified Beginner s Guide to Managing Analyzing and Manipulating Data With SQL Walter Shields https://ebookmeta.com/product/sql-quickstart-guide-the-simplified- beginner-s-guide-to-managing-analyzing-and-manipulating-data-with-sql- walter-shields/ ebookmeta.com Nephilim Prince 2 A Men s Fantasy Series Dark Star Series 1st Edition Troy Maverick https://ebookmeta.com/product/nephilim-prince-2-a-men-s-fantasy- series-dark-star-series-1st-edition-troy-maverick/ ebookmeta.com
  • 3. Take Control of iOS 15 and iPadOS 15 Josh Centers https://ebookmeta.com/product/take-control-of-ios-15-and- ipados-15-josh-centers/ ebookmeta.com Quantum Mechanics Mahesh C Jain https://ebookmeta.com/product/quantum-mechanics-mahesh-c-jain/ ebookmeta.com Always Eli Forever Love 1 1st Edition Charlie Novak https://ebookmeta.com/product/always-eli-forever-love-1-1st-edition- charlie-novak/ ebookmeta.com The Godsfall Chronicles 1st Edition Cocooned Cow https://ebookmeta.com/product/the-godsfall-chronicles-1st-edition- cocooned-cow/ ebookmeta.com Marginal Urbanisms Informal and Formal Development in Cities of Latin America 1st Edition Felipe Hernández https://ebookmeta.com/product/marginal-urbanisms-informal-and-formal- development-in-cities-of-latin-america-1st-edition-felipe-hernandez/ ebookmeta.com
  • 4. The Eye of the Crown Routledge Research in Early Modern History 1st Edition Kristin M.S. Bezio https://ebookmeta.com/product/the-eye-of-the-crown-routledge-research- in-early-modern-history-1st-edition-kristin-m-s-bezio/ ebookmeta.com
  • 6. CONTENTS IN DETAIL TITLE PAGE COPYRIGHT ABOUT THE AUTHOR PREFACE TO THE SECOND EDITION ACKNOWLEDGMENTS INTRODUCTION What Is SQL? Why SQL? Who Is This Book For? What You’ll Learn CHAPTER 1: SETTING UP YOUR CODING ENVIRONMENT Installing a Text Editor Downloading Code and Data from GitHub Installing PostgreSQL and pgAdmin Windows Installation macOS Installation Linux Installation Working with pgAdmin Launching pgAdmin and Setting a Master Password
  • 7. Connecting to the Default postgres Database Exploring the Query Tool Customizing pgAdmin Alternatives to pgAdmin Wrapping Up CHAPTER 2: CREATING YOUR FIRST DATABASE AND TABLE Understanding Tables Creating a Database Executing SQL in pgAdmin Connecting to the analysis Database Creating a Table Using the CREATE TABLE Statement Making the teachers Table Inserting Rows into a Table Using the INSERT Statement Viewing the Data Getting Help When Code Goes Bad Formatting SQL for Readability Wrapping Up CHAPTER 3: BEGINNING DATA EXPLORATION WITH SELECT Basic SELECT Syntax Querying a Subset of Columns Sorting Data with ORDER BY Using DISTINCT to Find Unique Values Filtering Rows with WHERE Using LIKE and ILIKE with WHERE
  • 8. Combining Operators with AND and OR Putting It All Together Wrapping Up CHAPTER 4: UNDERSTANDING DATA TYPES Understanding Characters Understanding Numbers Using Integers Auto-Incrementing Integers Using Decimal Numbers Choosing Your Number Data Type Understanding Dates and Times Using the interval Data Type in Calculations Understanding JSON and JSONB Using Miscellaneous Types Transforming Values from One Type to Another with CAST Using CAST Shortcut Notation Wrapping Up CHAPTER 5: IMPORTING AND EXPORTING DATA Working with Delimited Text Files Handling Header Rows Quoting Columns That Contain Delimiters Using COPY to Import Data Importing Census Data Describing Counties Creating the us_counties_pop_est_2019 Table Understanding Census Columns and Data Types Performing the Census Import with COPY
  • 9. Inspecting the Import Importing a Subset of Columns with COPY Importing a Subset of Rows with COPY Adding a Value to a Column During Import Using COPY to Export Data Exporting All Data Exporting Particular Columns Exporting Query Results Importing and Exporting Through pgAdmin Wrapping Up CHAPTER 6: BASIC MATH AND STATS WITH SQL Understanding Math Operators and Functions Understanding Math and Data Types Adding, Subtracting, and Multiplying Performing Division and Modulo Using Exponents, Roots, and Factorials Minding the Order of Operations Doing Math Across Census Table Columns Adding and Subtracting Columns Finding Percentages of the Whole Tracking Percent Change Using Aggregate Functions for Averages and Sums Finding the Median Finding the Median with Percentile Functions Finding Median and Percentiles with Census Data Finding Other Quantiles with Percentile Functions Finding the Mode
  • 10. Wrapping Up CHAPTER 7: JOINING TABLES IN A RELATIONAL DATABASE Linking Tables Using JOIN Relating Tables with Key Columns Querying Multiple Tables Using JOIN Understanding JOIN Types JOIN LEFT JOIN and RIGHT JOIN FULL OUTER JOIN CROSS JOIN Using NULL to Find Rows with Missing Values Understanding the Three Types of Table Relationships One-to-One Relationship One-to-Many Relationship Many-to-Many Relationship Selecting Specific Columns in a Join Simplifying JOIN Syntax with Table Aliases Joining Multiple Tables Combining Query Results with Set Operators UNION and UNION ALL INTERSECT and EXCEPT Performing Math on Joined Table Columns Wrapping Up CHAPTER 8: TABLE DESIGN THAT WORKS FOR YOU Following Naming Conventions Quoting Identifiers Enables Mixed Case
  • 11. Pitfalls with Quoting Identifiers Guidelines for Naming Identifiers Controlling Column Values with Constraints Primary Keys: Natural vs. Surrogate Foreign Keys How to Automatically Delete Related Records with CASCADE The CHECK Constraint The UNIQUE Constraint The NOT NULL Constraint How to Remove Constraints or Add Them Later Speeding Up Queries with Indexes B-Tree: PostgreSQL’s Default Index Considerations When Using Indexes Wrapping Up CHAPTER 9: EXTRACTING INFORMATION BY GROUPING AND SUMMARIZING Creating the Library Survey Tables Creating the 2018 Library Data Table Creating the 2017 and 2016 Library Data Tables Exploring the Library Data Using Aggregate Functions Counting Rows and Values Using count() Finding Maximum and Minimum Values Using max() and min() Aggregating Data Using GROUP BY Wrapping Up CHAPTER 10: INSPECTING AND MODIFYING DATA Importing Data on Meat, Poultry, and Egg Producers
  • 12. Interviewing the Dataset Checking for Missing Values Checking for Inconsistent Data Values Checking for Malformed Values Using length() Modifying Tables, Columns, and Data Modifying Tables with ALTER TABLE Modifying Values with UPDATE Viewing Modified Data with RETURNING Creating Backup Tables Restoring Missing Column Values Updating Values for Consistency Repairing ZIP Codes Using Concatenation Updating Values Across Tables Deleting Unneeded Data Deleting Rows from a Table Deleting a Column from a Table Deleting a Table from a Database Using Transactions to Save or Revert Changes Improving Performance When Updating Large Tables Wrapping Up CHAPTER 11: STATISTICAL FUNCTIONS IN SQL Creating a Census Stats Table Measuring Correlation with corr(Y, X) Checking Additional Correlations Predicting Values with Regression Analysis Finding the Effect of an Independent Variable with r-Squared Finding Variance and Standard Deviation
  • 13. Creating Rankings with SQL Ranking with rank() and dense_rank() Ranking Within Subgroups with PARTITION BY Calculating Rates for Meaningful Comparisons Finding Rates of Tourism-Related Businesses Smoothing Uneven Data Wrapping Up CHAPTER 12: WORKING WITH DATES AND TIMES Understanding Data Types and Functions for Dates and Times Manipulating Dates and Times Extracting the Components of a timestamp Value Creating Datetime Values from timestamp Components Retrieving the Current Date and Time Working with Time Zones Finding Your Time Zone Setting Setting the Time Zone Performing Calculations with Dates and Times Finding Patterns in New York City Taxi Data Finding Patterns in Amtrak Data Wrapping Up CHAPTER 13: ADVANCED QUERY TECHNIQUES Using Subqueries Filtering with Subqueries in a WHERE Clause Creating Derived Tables with Subqueries Joining Derived Tables Generating Columns with Subqueries
  • 14. Understanding Subquery Expressions Using Subqueries with LATERAL Using Common Table Expressions Performing Cross Tabulations Installing the crosstab() Function Tabulating Survey Results Tabulating City Temperature Readings Reclassifying Values with CASE Using CASE in a Common Table Expression Wrapping Up CHAPTER 14: MINING TEXT TO FIND MEANINGFUL DATA Formatting Text Using String Functions Case Formatting Character Information Removing Characters Extracting and Replacing Characters Matching Text Patterns with Regular Expressions Regular Expression Notation Using Regular Expressions with WHERE Regular Expression Functions to Replace or Split Text Turning Text to Data with Regular Expression Functions Full-Text Search in PostgreSQL Text Search Data Types Creating a Table for Full-Text Search Searching Speech Text Ranking Query Matches by Relevance Wrapping Up
  • 15. CHAPTER 15: ANALYZING SPATIAL DATA WITH POSTGIS Enabling PostGIS and Creating a Spatial Database Understanding the Building Blocks of Spatial Data Understanding Two-Dimensional Geometries Well-Known Text Formats Projections and Coordinate Systems Spatial Reference System Identifier Understanding PostGIS Data Types Creating Spatial Objects with PostGIS Functions Creating a Geometry Type from Well-Known Text Creating a Geography Type from Well-Known Text Using Point Functions Using LineString Functions Using Polygon Functions Analyzing Farmers’ Markets Data Creating and Filling a Geography Column Adding a Spatial Index Finding Geographies Within a Given Distance Finding the Distance Between Geographies Finding the Nearest Geographies Working with Census Shapefiles Understanding the Contents of a Shapefile Loading Shapefiles Exploring the Census 2019 Counties Shapefile Examining Demographics Within a Distance Performing Spatial Joins Exploring Roads and Waterways Data
  • 16. Joining the Census Roads and Water Tables Finding the Location Where Objects Intersect Wrapping Up CHAPTER 16: WORKING WITH JSON DATA Understanding JSON Structure Considering When to Use JSON with SQL Using json and jsonb Data Types Importing and Indexing JSON Data Using json and jsonb Extraction Operators Key Value Extraction Array Element Extraction Path Extraction Containment and Existence Analyzing Earthquake Data Exploring and Loading the Earthquake Data Working with Earthquake Times Finding the Largest and Most-Reported Earthquakes Converting Earthquake JSON to Spatial Data Generating and Manipulating JSON Turning Query Results into JSON Adding, Updating, and Deleting Keys and Values Using JSON Processing Functions Finding the Length of an Array Returning Array Elements as Rows Wrapping Up
  • 17. CHAPTER 17: SAVING TIME WITH VIEWS, FUNCTIONS, AND TRIGGERS Using Views to Simplify Queries Creating and Querying Views Creating and Refreshing a Materialized View Inserting, Updating, and Deleting Data Using a View Creating Your Own Functions and Procedures Creating the percent_change() Function Using the percent_change() Function Updating Data with a Procedure Using the Python Language in a Function Automating Database Actions with Triggers Logging Grade Updates to a Table Automatically Classifying Temperatures Wrapping Up CHAPTER 18: USING POSTGRESQL FROM THE COMMAND LINE Setting Up the Command Line for psql Windows psql Setup macOS psql Setup Linux psql Setup Working with psql Launching psql and Connecting to a Database Running SQL Queries on psql Navigating and Formatting Results Meta-Commands for Database Information Importing, Exporting, and Using Files
  • 18. Additional Command Line Utilities to Expedite Tasks Adding a Database with createdb Loading Shapefiles with shp2pgsql Wrapping Up CHAPTER 19: MAINTAINING YOUR DATABASE Recovering Unused Space with VACUUM Tracking Table Size Monitoring the Autovacuum Process Running VACUUM Manually Reducing Table Size with VACUUM FULL Changing Server Settings Locating and Editing postgresql.conf Reloading Settings with pg_ctl Backing Up and Restoring Your Database Using pg_dump to Export a Database or Table Restoring a Database Export with pg_restore Exploring Additional Backup and Restore Options Wrapping Up CHAPTER 20: TELLING YOUR DATA’S STORY Start with a Question Document Your Process Gather Your Data No Data? Build Your Own Database Assess the Data’s Origins Interview the Data with Queries Consult the Data’s Owner
  • 19. Identify Key Indicators and Trends over Time Ask Why Communicate Your Findings Wrapping Up APPENDIX: ADDITIONAL POSTGRESQL RESOURCES PostgreSQL Development Environments PostgreSQL Utilities, Tools, and Extensions PostgreSQL News and Community Documentation INDEX
  • 20. PRACTICAL SQL 2nd Edition A Beginner’s Guide to Storytelling with Data by Anthony DeBarros
  • 21. PRACTICAL SQL, 2ND EDITION. Copyright © 2022 by Anthony DeBarros. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. Printed in the United States of America First printing 25 24 23 22 21 1 2 3 4 5 6 7 8 9 ISBN-13: 978-1-7185-0106-5 (print) ISBN-13: 978-1-7185-0107-2 (ebook) Publisher: William Pollock Managing Editor: Jill Franklin Production Manager: Rachel Monaghan Production Editors: Jennifer Kepler and Paula Williamson Developmental Editor: Liz Chadwick Cover Illustrator: Josh Ellingson Interior Design: Octopod Studios Technical Reviewer: Stephen Frost Copyeditor: Kim Wimpsett Compositor: Maureen Forys, Happenstance Type-O-Rama Proofreader: Liz Wheeler For information on book distributors or translations, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 245 8th Street, San Francisco, CA 94103 phone: 1.415.863.9900; info@nostarch.com www.nostarch.com The Library of Congress has catalogued the first edition as follows: Names: DeBarros, Anthony, author. Title: Practical SQL : a beginner's guide to storytelling with data / Anthony DeBarros. Description: San Francisco : No Starch Press, 2018. | Includes index. Identifiers: LCCN 2018000030 (print) | LCCN 2017043947 (ebook) | ISBN 9781593278458 (epub) | ISBN 1593278454 (epub) | ISBN 9781593278274 (paperback) | ISBN 1593278276 (paperback) | ISBN 9781593278458 (ebook) Subjects: LCSH: SQL (Computer program language) | Database design. | BISAC: COMPUTERS / Programming Languages / SQL. | COMPUTERS / Database Management / General. | COMPUTERS / Database Management / Data Mining.
  • 22. Classification: LCC QA76.73.S67 (print) | LCC QA76.73.S67 D44 2018 (ebook) | DDC 005.75/6--dc23 LC record available at https://lccn.loc.gov/2018000030 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.
  • 23. About the Author Anthony DeBarros is a longtime journalist and early adopter of “data journalism,” the use of spreadsheets, databases, and code to find news in data. He’s currently a data editor for the Wall Street Journal, where he covers topics including the economy, trade, demographics, and the Covid-19 pandemic. Previously, he worked for the Gannett company at USA Today and the Poughkeepsie Journal and held product development and content strategy roles for Questex and DocumentCloud. About the Technical Reviewer Stephen Frost is the chief technology officer at Crunchy Data. He has been working with PostgreSQL since 2003 and general database technology since before then. Stephen began contributing to PostgreSQL development in 2004 and has been involved in the development of the role system, column-level privileges, row-level security, GSSAPI encryption, and the predefined roles system. He has also served on the board of the United States PostgreSQL Association and Software in the Public Interest, regularly speaks at PostgreSQL Community conferences and events, and works as a member of various PostgreSQL community teams.
  • 24. PREFACE TO THE SECOND EDITION Since the publication of the first edition of Practical SQL, I’ve received kind notes about the book from readers around the world. One happy reader said it helped him ace SQL questions on a job interview. Another, a teacher, wrote to say that his students remarked favorably about having the book assigned for class. Others just wanted to say thanks because they found the book helpful and a good read, two pieces of feedback that will warm the heart of most any author. I also sometimes heard from readers who hit a roadblock while working through an exercise or who had trouble with software or data files. I paid close attention to those emails, especially when the same question seemed to crop up more than once. Meanwhile, during my own journey of learning SQL—I use it every day at work— I’d often discover a technique and wish that I’d included it in the book. With all that in mind, I approached the team at No Starch Press with the idea of updating and expanding Practical SQL into a second edition. I’m thankful they said yes. This new version of the book is more complete, offers stronger guidance for readers related to software and code, and clarifies information that wasn’t as clear or presented as accurately as it could have been. The book has been
  • 25. thoroughly enjoyable to revisit, and I’ve learned much along the way. This second edition includes numerous updates, expansions, and clarifications in every chapter. Throughout, I’ve been careful to note when code syntax adheres to the SQL standard—meaning you can generally use it across database systems—or when the syntax is specific to the database used in the book, PostgreSQL. The following are among the most substantial changes: Two chapters are new. Chapter 1, “Setting Up Your Coding Environment,” details how to install PostgreSQL, pgAdmin, and additional PostgreSQL components on multiple operating systems. It also shows how to obtain the code listings and data from GitHub. In the first edition, this information was located in the introduction and occasionally missed by readers. Chapter 16, “Working with JSON Data,” covers PostgreSQL’s support for the JavaScript Object Notation data format, using datasets about movies and earthquakes. In Chapter 4 on data types, I’ve added a section on IDENTITY, the ANSI SQL standard implementation for auto-incrementing integer columns. Throughout the book, IDENTITY replaces the PostgreSQL- specific serial auto-incrementing integer type so that code examples more closely reflect the SQL standard. Chapter 5 on importing and exporting data now includes a section about using the WHERE keyword with the COPY command to filter which rows are imported from a source file to a table. I’ve removed the user-created median() function from Chapter 6 on basic math in favor of focusing exclusively on the SQL standard percentile_cont() function for calculating medians. In Chapter 7 on table joins, I’ve added a section covering the set operators UNION, UNION ALL, INTERSECT, and EXCEPT. Additionally, I’ve added a section covering the USING clause in joins to reduce redundant output and simplify query syntax.
  • 26. Chapter 10 on inspecting and modifying data includes a new section on using the RETURNING keyword in an UPDATE statement to display the data that the statement modified. I’ve also added a section that describes how to use the TRUNCATE command to remove all rows from a table and restart an IDENTITY sequence. In Chapter 11 on statistical functions, a new section demonstrates how to create a rolling average to smooth uneven data to get a better sense of trends over time. I’ve also added information on functions for calculating standard deviation and variance. Chapter 13 on advanced query techniques now shows how to use the LATERAL keyword with subqueries. One benefit is that, by combining LATERAL with JOIN, you get functionality similar to a for loop in a programming language. In Chapter 15 on analyzing spatial data, I demonstrate how to use the Geometry Viewer in pgAdmin to see geographies placed on a map. This feature was added to pgAdmin after publication of the first edition. In Chapter 17 on views, functions, and triggers, I’ve added information about materialized views and showed how their behavior differs from standard views. I also cover procedures, which PostgreSQL now supports in addition to functions. Finally, where practical, datasets have been updated to the most recent available at the time of writing. This primarily applies to US Census population statistics but also includes the text of presidential speeches and library usage statistics. Thank you for reading Practical SQL! If you have any questions or feedback, please get in touch by emailing practicalsqlbook@gmail.com.
  • 27. ACKNOWLEDGMENTS This second edition of Practical SQL is the work of many hands. My thanks, first, go to the team at No Starch Press. Thanks to Bill Pollock for capturing the vision and sharpening the initial concept for the book—and for agreeing to let me have another go at it. Special thanks and appreciation to senior editor Liz Chadwick, who improved each chapter with her insightful suggestions and deft editing, and to copyeditor Kim Wimpsett and the production team of Paula Williamson and Jennifer Kepler. Stephen Frost, chief technology officer at Crunchy Data and longtime contributor to the PostgreSQL community, served as the technical reviewer for this edition. I deeply appreciate the time Stephen took to explain the inner workings of PostgreSQL and SQL concepts. This book is better, more thorough, and more accurate thanks to his detailed eye. I’d also like to acknowledge Josh Berkus, whose many contributions as technical reviewer for the first edition persist in this new version. Thank you to Investigative Reporters and Editors (IRE) and its members and staff past and present for training journalists to find stories in data. IRE is where I got my start with SQL and data journalism. Many of my colleagues have not only imparted memorable lessons on data analysis, they’ve also made my workdays brighter. Special thanks to Paul Overberg for sharing his vast knowledge of demographics and the US Census, to Lou Schilling for many technical lessons, to Christopher Schnaars for his SQL expertise, to Peter Matseykanets for his encouragement, and to Chad Day, John
  • 28. West, and Maureen Linke and the WSJ DC visuals team for continual inspiration. My deepest appreciation goes to my dear wife, Elizabeth, and our sons. You are the brightest lights in my day. As we are fond of saying, “To the journey . . .”
  • 29. INTRODUCTION Shortly after joining the staff of USA Today, I received a dataset that I would analyze almost every week for the next decade. It was the weekly Best-Selling Books list, which ranked the nation’s top-selling titles based on confidential sales data. Not only did the list produce an endless stream of story ideas to pitch, it also captured the zeitgeist of America in a singular way. Did you know that cookbooks sell a bit more during the week of Mother’s Day or that Oprah Winfrey turned many obscure writers into number-one best-selling authors just by having them on her show? Every week, the book list editor and I pored over the sales figures and book genres, ranking the data in search of a new headline. Rarely did we come up empty: we chronicled everything from the rocket-rise of the blockbuster Harry Potter series to the fact that Oh, the Places You’ll Go! by Dr. Seuss had become a perennial gift for new graduates. My technical companion in that time was the database programming language SQL (for Structured Query Language). Early on, I convinced USA Today’s IT department to grant me access to the SQL-based database system that powered our book list application. Using SQL, I was able to discover the stories hidden in the database,
  • 30. which contained sales data related to titles, authors, genres, and the codes that defined the publishing world. SQL has been useful to me ever since, whether my role was in product development, in content strategy, or, lately, as a data editor for the Wall Street Journal. In each case, SQL has helped me find interesting stories in data—and that’s exactly what you’ll learn to do using this book. What Is SQL? SQL is a widely used programming language for managing data and database systems. Whether you’re a marketing analyst, a journalist, or a researcher mapping neurons in the brain of a fruit fly, you’ll benefit from using SQL to collect, modify, explore, and summarize data. Because SQL is a mature language that’s been around for decades, it’s ingrained in many modern systems. A pair of IBM researchers first outlined the syntax for SQL (then called SEQUEL) in a 1974 paper, building on the theoretical work of the British computer scientist Edgar F. Codd. In 1979, a precursor to the database company Oracle (then called Relational Software) became the first to use the language in a commercial product. Today, SQL still ranks as one of the most-used computer languages in the world, and that’s unlikely to change soon. Each database system, such as PostgreSQL, MySQL or Microsoft SQL Server, implements its own variant of SQL, so you’ll notice subtle—or sometimes significant—differences in syntax if you jump from one system to another. There are several reasons behind this. The American National Standards Institute (ANSI) adopted a standard for SQL in 1986, followed by the International Organization for Standardization (ISO) in 1987. But the standard doesn’t cover all aspects of SQL that are required for a database implementation—for example, it has no entry for creating indexes. That leaves each database system maker to choose how to implement features the
  • 31. standard doesn’t cover—and no database maker currently claims to conform to the entire standard. Meanwhile, business considerations can lead commercial database vendors to create nonstandard SQL features for both competitive advantage and as a way to keep users in their ecosystem. For example, Microsoft’s SQL Server uses the proprietary Transact-SQL (T-SQL) that includes a number of features not in the SQL standard, such as its syntax for declaring local variables. Migrating code written using T-SQL to another database system may not be trivial, therefore. In this book, the examples and code use the PostgreSQL database system. PostgreSQL, or simply Postgres, is a robust application that can handle large amounts of data. Here are some reasons PostgreSQL is a great choice to use with this book: It’s free. It’s available for Windows, macOS, and Linux operating systems. Its SQL implementation aims to closely follow the SQL standard. It’s widely used, so finding help online is easy. Its geospatial extension, PostGIS, lets you analyze geometric data and perform mapping functions and is often used with mapping software such as QGIS. It’s available in cloud computing environments such as Amazon Web Services and Google Cloud. It’s a common choice as a data store for web applications, including those powered by the popular web framework Django. The good news is that the fundamental concepts and much of the core SQL syntactical conventions of PostgreSQL will work across databases. So, if you’re using MySQL at work, you can employ much of what you learn here—or easily find parallel code concepts. When syntax is PostgreSQL-specific, I make sure to point that out. If you need to learn the SQL syntax of a system with features that deviate
  • 32. from the standard, such as Microsoft SQL Server’s T-SQL, you may want to further explore a resource focusing on that system. Why SQL? SQL certainly isn’t the only option for crunching data. Many people start with Microsoft Excel spreadsheets and their assortment of analytic functions. After working with Excel, they might graduate to Access, the database system built into some versions of Microsoft Office, which has a graphical query interface that makes it easy to get work done. So why learn SQL? One reason is that Excel and Access have their limits. Excel currently allows 1,048,576 rows maximum per worksheet. Access limits database size to two gigabytes and limits columns to 255 per table. It’s not uncommon for datasets to surpass those limits. The last obstacle you want to discover while facing a deadline is that your database system doesn’t have the capacity to get the job done. Using a robust SQL database system allows you to work with terabytes of data, multiple related tables, and thousands of columns. It gives you fine-grained control over the structure of your data, leading to efficiency, speed, and—most important—accuracy. SQL is also an excellent adjunct to programming languages used in the data sciences, such as R and Python. If you use either language, you can connect to SQL databases and, in some cases, even incorporate SQL syntax directly into the language. For people with no background in programming languages, SQL often serves as an easy-to-understand introduction into concepts related to data structures and programming logic. Finally, SQL is useful beyond data analysis. If you delve into building online applications, you’ll find that databases provide the backend power for many common web frameworks, interactive maps, and content management systems. When you need to dig beneath the surface of these applications, the ability to manage data and databases with SQL will come in very handy.
  • 34. Who Is This Book For? Practical SQL is for people who encounter data in their everyday lives and want to learn how to analyze, manage, and transform it. With that in mind, we cover real-world data and scenarios, such as US Census demographics, crime reports, and data about taxi rides in New York City. We aim to understand not only how SQL works but how we can use it to find valuable insights. This book was written with people new to programming in mind, so the early chapters cover key basics about databases, data, and SQL syntax. Readers with some SQL experience should benefit from later chapters that cover more advanced topics, such as Geographical Information Systems (GIS). I assume that you know your way around your computer, including how to install programs, navigate your hard drive, and download files from the internet, but I don’t assume you have any experience with programming or data analysis. What You’ll Learn Practical SQL starts with a chapter on setting up your system and getting the code and data examples and then moves through the basics of databases, queries, tables, and data that are common to SQL across many database systems. Chapters 14 to 19 cover topics more specific to PostgreSQL, such as full-text search, functions, and GIS. Although many chapters in this book can stand alone, you should work through the book sequentially to build on the fundamentals. Datasets presented in early chapters often reappear later, so following the book in order will help you stay on track. The following summary provides more detail about each chapter: Chapter 1: Setting Up Your Coding Environment walks through setting up PostgreSQL, the pgAdmin user interface, and a text editor, plus how to download example code and data.
  • 35. Chapter 2: Creating Your First Database and Table provides step-by-step instructions for the process of loading a simple dataset about teachers into a new database. Chapter 3: Beginning Data Exploration with SELECT explores basic SQL query syntax, including how to sort and filter data. Chapter 4: Understanding Data Types explains the definitions for setting columns in a table to hold specific types of data, from text to dates to various forms of numbers. Chapter 5: Importing and Exporting Data explains how to use SQL commands to load data from external files and then export it. You’ll load a table of US Census population data that you’ll use throughout the book. Chapter 6: Basic Math and Stats with SQL covers arithmetic operations and introduces aggregate functions for finding sums, averages, and medians. Chapter 7: Joining Tables in a Relational Database explains how to query multiple, related tables by joining them on key columns. You’ll learn how and when to use different types of joins. Chapter 8: Table Design that Works for You covers how to set up tables to improve the organization and integrity of your data as well as how to speed up queries using indexes. Chapter 9: Extracting Information by Grouping and Summarizing explains how to use aggregate functions to find trends in US library usage based on annual surveys. Chapter 10: Inspecting and Modifying Data explores how to find and fix incomplete or inaccurate data using a collection of records about meat, egg, and poultry producers as an example. Chapter 11: Statistical Functions in SQL introduces correlation, regression, ranking, and other functions to help you derive more meaning from datasets.
  • 36. Chapter 12: Working with Dates and Times explains how to create, manipulate, and query dates and times in your database, including working with time zones and with data about New York City taxi trips and Amtrak train schedules. Chapter 13: Advanced Query Techniques explains how to use more complex SQL operations such as subqueries and cross tabulations, plus the CASE statement, to reclassify values in a dataset on temperature readings. Chapter 14: Mining Text to Find Meaningful Data covers how to use PostgreSQL’s full-text search engine and regular expressions to extract data from unstructured text, using police reports and a collection of speeches by US presidents as examples. Chapter 15: Analyzing Spatial Data with PostGIS introduces data types and queries related to spatial objects, which will let you analyze geographical features such as counties, roads, and rivers. Chapter 16: Working with JSON Data introduces the JavaScript Object Notation (JSON) data format and uses data about movies and earthquakes to explore PostgreSQL JSON support. Chapter 17: Saving Time with Views, Functions, and Triggers explains how to automate database tasks so you can avoid repeating routine work. Chapter 18: Using PostgreSQL from the Command Line covers how to use text commands at your computer’s command prompt to connect to your database and run queries. Chapter 19: Maintaining Your Database provides tips and procedures for tracking the size of your database, customizing settings, and backing up data. Chapter 20: Telling Your Data’s Story provides guidelines for generating ideas for analysis, vetting data, drawing sound conclusions, and presenting your findings clearly. Appendix: Additional PostgreSQL Resources lists software and documentation to help you grow your skills.
  • 37. Each chapter ends with a “Try It Yourself” section that contains exercises to help you reinforce the topics you learned. Ready? Let’s begin with Chapter 1, “Setting Up Your Coding Environment.”
  • 38. 1 SETTING UP YOUR CODING ENVIRONMENT Let’s begin by installing the resources you’ll need to complete the exercises in the book. In this chapter, you’ll install a text editor, download the example code and data, and then install the PostgreSQL database system and its companion graphical user interface, pgAdmin. I’ll also tell you how to get help if you need it. When you’re finished, your computer will have a robust environment for you to learn how to analyze data with SQL. Avoid the temptation to skip ahead to the next chapter. My high school teacher (clearly a fan of alliteration) used to tell us that “proper planning prevents poor performance.” If you follow all the steps in this chapter, you’ll avoid headaches later. Our first task is to set up a text editor suitable for working with data.
  • 39. Installing a Text Editor The source data you’ll add to a SQL database is typically stored in multiple text files, often in a format called comma-separated values (CSV). You’ll learn more about the CSV format in Chapter 5, in the section “Working with Delimited Text Files,” but for now let’s make sure you have a text editor that will let you open those files without inadvertently harming the data. Common business applications—word processors and spreadsheet programs—tend to introduce styles or hidden characters into files without asking, and that makes using them for data work problematic, as data software expects data in precise formats. For example, if you open a CSV file with Microsoft Excel, the program will automatically alter some data to make it more human-readable; it will assume, for example, that an item code of 3-09 is a date and format it as 9-Mar. Text editors deal exclusively with plain text with no embellishments such as formatting, and for that reason programmers use them to edit files that hold source code, data, and software configurations—all cases where you want your text to be treated as text, and nothing more. Any text editor should work for the book’s purposes, so if you have a favorite, feel free to use it. Here are some I have used and recommend. Except where noted, they are free and available for macOS, Windows, and Linux. Visual Studio Code by Microsoft: https://code.visualstudio.com/ Atom by GitHub: https://atom.io/ Sublime Text by Sublime HQ (free to evaluate but requires purchase for continued use): https://www.sublimetext.com/ Notepad++ by author Don Ho (Windows only): https://notepad- plus-plus.org/ (note that this is a different application than Notepad.exe, which comes with Windows) More advanced users who prefer to work in the command line may want to use one of these two text editors, which are installed by
  • 40. default in macOS and Linux: vim by author Bram Moolenaar and the open source community: https://www.vim.org/ GNU nano by author Chris Allegretta and the open source community: https://www.nano-editor.org/ If you don’t have a text editor, download and install one and get familiar with the basics of opening folders and working with files. Next, let’s get the book’s example code and data. Downloading Code and Data from GitHub All of the code and data you’ll need for working through the book’s exercises are available for download. To get it, follow these steps: Visit the book’s page on the No Starch Press website at https://nostarch.com/practical-sql-2nd-edition/. On the page, click Download the code from GitHub to visit the repository on https://github.com/ that holds the material. On the Practical SQL 2nd Edition page at GitHub, you should see a Code button. Click it, and then select Download ZIP to save the ZIP file to your computer. Place it in a location where you can easily find it, such as your desktop. (If you’re a GitHub user, you can also clone or fork the repository.) Unzip the file. You should then see a folder named practical-sql-2- master that contains the various files and subfolders for the book. Again, place this folder where you can easily find it.
  • 41. NOTE Windows users will need to provide permission for the PostgreSQL database you will install to read and write to the contents of the practical-sql-2-master folder. To do so, right- click the folder, click Properties, and click the Security tab. Click Edit and then Add. Type the name Everyone into the object names box and click OK. Highlight Everyone in the user list, select all boxes under Allow, and then click Apply and OK. Inside the practical-sql-2-master folder, for each chapter you’ll find a subfolder named Chapter_XX (XX is the chapter number). Inside subfolders, each chapter that includes code examples will also have a file named Chapter_XX that ends with a .sql extension. This is a SQL code file that you can open with your text editor or with the PostgreSQL administrative tool you’ll install later in this chapter. Note that in the book several code examples are truncated to save space, but you’ll need the full listing from the .sql file to complete the exercise. You’ll know an example is truncated when you see --snip- - in the listing. The chapter folders also contain the public data you’ll use in the exercises, stored in CSV and other text-based files. As noted, it’s fine to view CSV files with a true text editor, but don’t open these files with Excel or a word processor. Now, with the prerequisites complete, let’s load the database software. Installing PostgreSQL and pgAdmin In this section, you’ll install both the PostgreSQL database system and a companion graphical administrative tool, pgAdmin. Think of pgAdmin as a helpful visual workspace for managing your PostgreSQL database. Its interface lets you see your database
  • 42. objects, manage settings, import and export data, and write queries, which is the code that retrieves data from your database. One benefit of using PostgreSQL is that the open source community has provided excellent guidelines that make it easy to get PostgreSQL up and running. The following sections outline installation for Windows, macOS, and Linux as of this writing, but the steps might change as new versions of the software or operating systems are released. Check the documentation noted in each section as well as the GitHub repository with the book’s resources; I’ll maintain files there with updates and answers to frequently asked questions. NOTE I recommend you install the latest available version of PostgreSQL for your operating system to ensure that it’s up- to-date on security patches and new features. For this book, I’ll assume you’re using version 11.0 or later. Windows Installation For Windows, I recommend using the installer provided by the company EDB (formerly EnterpriseDB), which offers support and services for PostgreSQL users. When you download the PostgreSQL package bundle from EDB, you also get pgAdmin and Stack Builder, which includes a few other tools you’ll use in this book and throughout your SQL career. To get the software, visit https://www.postgresql.org/download/windows/ and click Download the installer in the EDB section. This should lead to a downloads page on the EDB site. Select the latest available 64-bit Windows version of PostgreSQL unless you’re using an older PC with 32-bit Windows.
  • 43. NOTE The following section covers installation for Windows 10. If you’re using Windows 11, please check the GitHub repository with the book’s resources for notes about any adjustments to these instructions. After you download the installer, follow these steps to install PostgreSQL, pgAdmin, and additional components: Right-click the installer and select Run as administrator. Answer Yes to the question about allowing the program to make changes to your computer. The program will perform a setup task and then present an initial welcome screen. Click through it. Choose your installation directory, accepting the default. On the Select Components screen, select the boxes to install PostgreSQL Server, the pgAdmin tool, Stack Builder, and the command line tools. Choose the location to store data. You can choose the default, which is in a data subdirectory in the PostgreSQL directory. Choose a password. PostgreSQL is robust with security and permissions. This password is for the default initial database superuser account, which is called postgres. Select the default port number where the server will listen. Unless you have another database or application using it, use the default, which should be 5432. You can substitute 5433 or another number if you already have an application using the default port. Select your locale. Using the default is fine. Then click through the summary screen to begin the installation, which will take several minutes. When the installation is done, you’ll be asked whether you want to launch EnterpriseDB’s Stack Builder to obtain additional packages.
  • 44. Make sure the box is checked and click Finish. When Stack Builder launches, choose the PostgreSQL installation on the drop-down menu and click Next. A list of additional applications should download. Expand the Spatial Extensions menu and select the PostGIS Bundle for the version of PostgreSQL you installed. You may see more than one listed; if so, choose the newest version. Also, expand the Add- ons, tools and utilities menu and select EDB Language Pack, which installs support for programming languages including Python. Click through several times; you’ll need to wait while the installer downloads the additional components. When installation files have been downloaded, click Next to install the language and PostGIS components. For PostGIS, you’ll need to agree to the license terms; click through until you’re asked to Choose Components. Make sure PostGIS and Create spatial database are selected. Click Next, accept the default install location, and click Next again. Enter your database password when prompted and continue through the prompts to install PostGIS. Answer Yes when asked to register the PROJ_LIB and GDAL_DATA environment variables. Also, answer Yes to the questions about setting POSTGIS_ENABLED_DRIVERS and enabling the POSTGIS_ENABLE_OUTDB_RASTERS environment variable. Finally, click through the final Finish steps to complete the installation and exit the installers. Depending on the version, you may be prompted to restart your computer. When finished, you should have two new folders in your Windows Start menu: one for PostgreSQL and another for PostGIS. If you’d like to get started right away, you can skip ahead to the section “Working with pgAdmin.” Otherwise, follow the steps in the next section to set environment variables for optional Python language support. We cover using Python with PostgreSQL in
  • 45. Discovering Diverse Content Through Random Scribd Documents
  • 46. deadly work they had begun, was hourly expected; but they did not come, and at last it dawned upon the minds of those in authority that, seeing they were within entrenchments, a smaller number of soldiers might serve to guard them. It took some time for this idea to work in the official mind; but, at last, to the intense satisfaction of the soldiers and regimental officers, five hundred men were told off to join the English force which was supposed to be marching on Delhi. It was on the 23rd that the General encountered the detachment from his mutinous regiment in the wood; and, early on the 24th, the force from Meerut was to be in readiness to march. Hence the ambush. The rebels, whose intelligence department was much better managed than ours—they had spies everywhere—knowing exactly what was going to happen, had imagined that, through the General, whom, they believed, they could easily entrap, they might paralyse the action of the English, so far, at least, as to delay, for some days, the march of a detachment from Meerut. They had, as we have seen, most grossly miscalculated. But, meanwhile, the firing had been heard at Meerut, and a gallant young officer, well known to the General, who had been burning to distinguish himself and to redeem the honour of the English arms, gained permission to go out and reconnoitre with a party of fifty horsemen. It was late in the evening; but the moon was well up, and there was light enough to guide them to the scene of the little skirmish. It was over by the time they rode out upon the plain. The General and his men had taken their own vengeance; but, exhausted as they were, their chief wounded, their horses dead-beat, and their situation precarious—since, for all they knew to the contrary, the woods behind them might be full of rebels—the sight of this little band of their countrymen coming out to meet them was, beyond expression, cheering. 'They are not all dead then, thank God!' said the General. 'Two of you gallop out to meet them, boys, and tell them how it is with us.'
  • 47. 'Can you sit a horse, sir,' said Tommy, 'or shall we send for a litter?' 'Litter! Nonsense! I'm not going to give up the ghost yet,' said the old soldier, testily. 'But,' to himself, 'I shan't mind being at home. I believe the scoundrel spoke the truth so far. Poor little monkeys! I wonder which of them is hurt. Oh, God, if I had only listened to reason, and left them all at home!' 'Do you want anything, sir?' said one of his men, who saw him speaking, but could not catch his voice. 'No, thank you,' he answered, 'except to get away from this. Ah! here they are! Friends this time, not foes! Welcome, Bertie,' to the young officer, who had sprung from his horse, and was looking down upon him mournfully. 'Don't look so glum, you young rascal. They are safe?' sharply. 'Your people escaped, General. One of the young ladies was hurt, not seriously, I believe. Lady Elton has been in the most terrible state of anxiety.' 'No doubt! No doubt! Well, I shall hear all about it from themselves soon. Lift me into a saddle, Bertie. We'd better be moving.' Kullum Khan, who was sobbing like a child, took the General under one arm, the young officer under the other, and in a few moments they had him mounted on the quietest and strongest of the horses, a trooper getting up behind him, to keep him in his place. Then, carrying the wounded Indians between them, the cavalcade set off across the plain. The mango grove where the skirmish had begun was within three miles of Meerut; but as, for the sake of the wounded, they were obliged to move slowly, the transit took some time. Scouts, meanwhile, were thrown out in every direction, to keep the coasts clear, and warn them of danger. But there was not even an alarm. The combatants, as the General said grimly, were on their faces, and the non-combatants kept out of their way.
  • 48. They came upon the outskirts of Meerut. The General was moaning heavily, with pain and anguish. There was nothing now to keep up his proud heart, and it fell. He knew all the landmarks, and each one had some memory for him. There was the little grove where, one glorious evening, he and his men had picnicked when they came down upon Meerut from the Sikh war, to enjoy a little rest after the hardships of the campaign. How splendid they had looked, and how handy and helpful they were, living on next to nothing, and going through fatigue and privation that would have floored half a European regiment! And now they were close on the cantonments. He had built several of the bungalows here and laid out their gardens—the mess-house for the officers of his regiment, the colonel's house, the spacious and beautiful bungalow, finished while he was in England, to which only a few weeks before he had brought his wife and children. This last was outside cantonments and nearer to the native lines than any other English house. He remembered now, pacing slowly and sadly over the blackened ground, with the charred ruins of what had so lately been a happy home staring him in the face, how one or two had warned him that, in case of a rising, the situation would be dangerous, and how proudly he had smiled at the absurdity of the notion. 'While my family and I are in the station,' he said, 'a rising would be impossible, and I don't ask anyone else to occupy the house.' And now it was literally gutted. As they were crossing what had been the garden of the General's bungalow, an old man came out from the ruins and confronted them. The young officer who, with drawn sword, was leading the cavalcade, would have swept him aside, but he cried out so piteously to be heard that the General, who was some yards behind, ordered that he should be brought to him. 'I think I know your voice,' he said.
  • 49. 'The Sahib should know,' replied the man, weeping bitterly; 'for I have served him these twenty years.' 'You are Yaseen Khan, my bearer.' 'I am Yaseen Khan, Sahib General, and my son Kullum——' 'I am here, Yaseen,' said the Sepoy from behind. 'I could not go on, and I slew Koolraj Sing, who tried to deceive me.' 'The gods be praised!' murmured the old man. 'Sahib, by the God you worship, I beseech you to take me on with you!' 'Why are you here, Yaseen Khan?' said the General. 'Have patience, Excellency, and I will tell you everything. They surrounded this house and set it on fire in three places. Then I ran to the lines and called my son, Kullum, who, with Soubahdar Sufder Jung and others, came up, and the budmashes fled. Trixy Sahib was hurt; I know not how. They carried her in their arms—my son Kullum and the Soubahdar—as if she had been their own child. The others walked, for no carriage was to be found; but the men guarded them carefully, and not a hair of their heads was touched. I thought of the General Sahib's gold, and I went back to get it. I could not carry it away; but I buried it in a secret place. Then the budmashes came round the house again, yelling like evil spirits. They found me, and said they would kill me if I did not find them gold. I said I would find it, and, in going, I escaped. I was close to them, Sahib, and I heard their cries. They would have torn me to pieces if they had found me; but there was an alarm. Some one said, "The Sahibs are coming!" and they ran out, and I saw and heard them no more. But I dared not move; I kept in hiding, waiting for your Honour's return, and living on the food I could pick up. For two days I have not eaten. Have pity on me, Sahib, and take me on!' 'Mount him on one of the horses, and bring him on behind me,' said the General. 'I believe that what he tells me is the truth.' A few moments later they came upon the vedettes, and then, the young officer having answered the challenge, they entered the town.
  • 50. Here the General insisted upon dismounting. 'I can't present myself to my wife and children in this guise,' he said. 'Dismiss your men to their quarters, Bertie, and let them find quarters for my men, and for the natives who were faithful. You give me your arm and we will find Lady Elton.' The officer gave the necessary directions, adding, on his own account, that the surgeon of his regiment should be sent to the General's quarters, and they set off together, the General leaning heavily on the arm of his guide, and Yaseen Khan, the bearer, following them. Lady Elton and her children were under canvas. They had preferred this arrangement to accepting shelter from any of the houses thrown open to them, and the Soubahdar and his men having succeeded in saving many of their things, they had been able already to give their new quarters a tolerably home-like appearance. It was only in this way—in exerting themselves to set things straight 'for father,' who, they felt sure, must come in soon—that the girls could keep their mother cheerful, or that any of them could chase away the terrible despondency and shuddering fear which would, at times, take possession of them. For upon these unfortunate ladies, bred up in the traditions of the old Anglo-Indian, who looked upon a native as a cross between a machine and an animal—a creature to be treated with kindly contempt when he behaved himself, and to be promptly licked into shape when he did not—the mutiny fell like a bolt of fire out of a clear sky. They had heard rumours of discontent, but nothing came of them. They were disposed to think that the repressive measures had not been sufficiently severe, and when on May 9 the mutineers of the 3rd Native Cavalry, who had been condemned by their own countrymen, and sentenced to ten years' imprisonment, were stripped of their uniform and put in irons, while sorry for the unhappy men who had been so miserably deluded, they believed that this one severe example would be sufficient, and that no more would be heard of mutiny. Lady Elton was fond of quoting her husband in those days. 'The General says all they want is
  • 51. firmness. They are the best fellows in the world when you take them the right way. He ought to know, for he has had so much experience.' And then Maud would repeat her saucy little phrase about the riding-whip, and the ladies, who had come to consult them, would go away reassured. 'You may depend upon it,' they would say, 'General Elton and his wife know more about these people than we do.' To be awakened from this dream of security by the rattle of musketry from the lines; and, after a few minutes of terror-stricken silence, the tramp of armed men upon the plain, and the shock of contending forces, was terrible beyond description. How, stirred up by Yaseen Khan, who ran in hot haste for his son, they barricaded themselves into the innermost room of the bungalow, piling furniture against the doors to keep out the mutineers; how, sitting huddled together, clasped in one another's arms, they heard the defiant shouts and yells of rage come nearer and nearer; how Trixy, the first to recover presence of mind, climbed up to a peep-hole under the roof, and came back with the awful intelligence that the stables and kitchens were in flames; how they heard the wretches, who were mad with bhang and fanaticism, getting on to the roof; then the yell, when the thatch was torn aside, and one of the fierce creatures looked down on them; the screams of the girls, and brave little Trixy's pistol-shot, followed by a shriek from the first scoundrel, and a shot from the man behind him, which brought the poor girl to the ground,—all this lives still in these poor women's remembrance as a dream of horror! They were rescued as we have seen. Those surrounding the General's house were budmashes from the bazaars and the criminals who had rushed out when the gaol doors were opened, and at the approach of the disciplined force under Soubahdar Sufder Jung every one of them took to their heels. The ladies, half dead with fright, and some of their choicest possessions, were escorted safely to the English barracks, where they lodged that night. Then began that weary waiting-time, which to poor Lady Elton was even worse than the scene of horror through which they had passed. Her
  • 52. husband was away. She had not heard from him for some days, and did not know where he was. Her beloved eldest daughter Grace and her niece, only lately married, were in the heart of a district said to be unsettled before, and which now, when this terrible news from Meerut went abroad, would be almost certain to rise. She had friends at Cawnpore, friends at Delhi, friends at Jhansi. None of them all were so well guarded as they of Meerut. If massacre and destruction could run riot here, what would it be there? Day by day she looked for her husband's arrival. She never feared for his personal safety. She had still the firmest belief in his power over the native soldiery; but if he came something might be done. For this made one element in the misery of the old soldier's wife and daughters. Nothing was being done. 'If I were in command here,' Trixy would say, clenching her little fists, 'not one of those brutes should have reached Delhi. Bertie Liston says the men were burning to be off. He could scarcely keep them quiet. I think I should have let them go—gone with them.' 'Trixy is a great warrior since she fired that pistol,' said Maud; 'but, seriously, mother, don't you think something ought to be done?' 'My dear children, be patient! We are women. We know nothing. Soldiers must obey orders,' said Lady Elton sadly. 'If your father would only come!' 'He will come soon, mother darling, don't be afraid,' said gentle little Lucy. Some such conversation as this had taken place on the afternoon of the day when firing was heard outside the walls. The five women heard it distinctly as they sat over their tea in the tent. Then Bertie Liston came rushing in with a radiant face. 'Good-bye,' he said, 'I am sent out to reconnoitre. What will you give me if I bring you back the General?' 'Anything, everything—all we have,' cried Trixy impulsively. She was lying on a charpoy, for she had not yet recovered from her wound. Bertie looked at her, and her pale face flushed; but there was time
  • 53. for no more words. He went out: she heard his horse's hoofs clattering over the paving-stones in the compound of the barracks, and covering her face with her hands she burst into tears. An hour or more passed by. The firing outside had ceased. Nothing could be heard but the pacing of the sentinels and the chowkedars crying out one to the other. Darkness had fallen; but the little company in the tent did not stir. Then Maud, crying out that she could stand it no longer, lighted a lamp; Trixy, who was very much ashamed of her little outburst, asked for a book, and Lady Elton fell back upon her never-failing resource—the silk stockings she was knitting for the General. 'Do you think, dears,' she said to the two youngest girls, Lucy and Mildred, 'that you could sing one of your duets? If father did come home to-night, it would please him to hear your voices.' They said they would try, and in a few moments their sweet clear young voices rose above the stillness. It was one of the sentimental ditties that we used to admire in those days, neither the words of the song nor the music to which it was set of a particularly high order; but as, supported by his young friend, the old General approached the lighted tent, and heard in his girls' sweet voices of wild waves whispering and red roses fading away, his heart thrilled with a rapture such as no artistic music could have given. 'Bless them,' he said, in a low and heartfelt voice. 'All right, isn't it, Bertie? They couldn't sing like that if the shock had been too much for them. There! what an old donkey I am! I knew the children had the pluck of—Come on, Bertie. They are stopping. They hear us. Back, Yaseen Khan, you old fool! I don't want you to announce me.' And now the curtain before the tent is thrown aside, and he sees them—his sweet wife and the children, who are dearer to him than his life, and his stern eyes fill with tears, and the voice of thunder, which only a few moments before had roared out defiance to a hundred foes, is as weak as that of a little child. 'Well, here I am! How are you all?' he says, feebly.
  • 54. He is in the gloom; they are in the light. They have not seen, but they have heard. In a moment they spring up, all but poor Trixy, who is crying quietly, and there are cries of 'Wilfrid! Thank God! Father! Father!' And a little voice from the corner is heard to say, 'Bertie has brought him. Don't let Bertie go away!' All at once there is a lull. They have drawn him under the light, and they see that his face is pale and drawn, and one of them discovers that his arm is roughly bandaged. 'Father has been wounded. Children, don't press round him so,' cries Lady Elton. 'Will some one run for a doctor?' 'The Doctor Sahib is here,' says a voice outside; a quiet voice, which contrasts strangely with the agitated tones of those within the tent. In the next instant Yaseen Khan, the bearer, clad in snow-white tunic and dhootie, and having on his head a voluminous turban—how he had set himself in order no one ever knew—steps forward, and having, with his usual dignity, saluted those in the tent, ushers in the doctor. Then from that irrepressible little person in the corner there comes a peal of laughter. 'Bravo, Yaseen Khan!' she cries. 'You are decidedly master of the situation. Have you been hiding yourself in a band-box all this time, you most unconscionable old man?' Yaseen Khan merely salaams and smiles. He is busy attending to his master, and has no time for banter. CHAPTER XXII THE RAJAH SURPRISED It was on that very night, the night of the 23rd of May, that Hoosanee returned to Gumilcund, after his unsuccessful effort to save Grace Elton and her cousin. He reported himself to his master
  • 55. at once, and gave an account of what he had done. It was his opinion that the rising at Nowgong would be speedy and cruel. Many of the Sahibs, he said, were disliked by the people and soldiers, and would not be spared. He did not venture to repeat his conversation with the chuprassie; but he said that he believed there was one servant in the Captain Sahib's service who might be trusted. 'The lotus-eyed,' he averred, must be saved at all hazards, and he offered, should his master desire it, to go to the station again, and to linger about in disguise, watching over her, until the danger was over, or the rising had come. In case of a rising, he would provide for some temporary refuge in the neighbourhood, whence, if they could not escape in any other way, his master would fetch them at the point of the sword. Tom agreed to the proposal, suggesting only that he should go in place of Hoosanee; or, if that were impossible, that they should go together. But both his servant and Chunder Singh, who was present, pointed out to him so clearly that his presence, instead of helping, might spoil everything, that he was obliged to give way. Hoosanee should have the honour and joy of watching over the sweetest woman on all the earth; Chunder Singh should hold himself in readiness to obey the first summons to arms, and Tom had spies posted in the different villages on the route between Nowgong and Gumilcund, so that Hoosanee's messages might be passed on from one to another, and that help could reach him speedily. He was himself meditating a dangerous enterprise, nothing less than marching into Jhansi alone, presenting himself before the Ranee, and persuading her, under promise of his personal support, and his influence with the Government in case of her failure—for he had now certain knowledge that she intended soon to raise the standard of revolt—to allow him to carry off to Gumilcund the English women and children in the station. But many things had to be done before he could start. June was nearly in when, riding Snow-queen, and dressed as an Indian of rank, he left Gumilcund. In despite of all Chunder Singh urged to the
  • 56. contrary, he was unattended, it being his belief that the Ranee would be more likely to listen to him if he entered her palace alone. The hot season being well in, he travelled principally at night, resting by day in a grove or peasant's hut. He was treated with consideration everywhere. Now and then a greybeard would reprove him for travelling so heedlessly in these unsettled times, and once or twice he was asked his business. To this he would answer that he was a kinsman of the Ranee of Jhansi, and that she had sent for him; but that what her will was he knew not. Everything, in fact, went well, so that, but for the adventure I am about to relate, he would have been in Jhansi before the rising; and it is just possible that, by his influence, the memory of a proud and not ungenerous woman would have been saved from a foul blot, and many innocent people delivered from destruction. He came to within a few miles of the borders of Jhansi. For the last two days he had been pressing his pace, for sinister rumours were abroad, and he feared to be too late. But there had been terrible rain, and the ways were miry, and Snow-queen was hanging her head dejectedly. For her sake rather than his own he determined to rest for a few hours. There was a village close by. He rode in slowly, and asked for the house of the headman, where, after a little parley, he was allowed to rest, while he watched his horse being fed and watered. He was on the little mud platform in front of the house. Snow-queen was tethered close by. It was mid-day and the place was silent as the grave, so that presently, in spite of strenuous efforts to hold his eyes open, he fell into a dog's sleep. How long it lasted he could not tell. He was aroused by the trampling of feet and clamour of many voices. He sprang up, and, almost at the same moment, the headman came to him, with a strange look in his eyes. 'You must go on,' he said, 'the Ranee is here.' 'Ranee—what ranee—of Jhansi?' he asked. 'I know not,' the man answered; 'but we want this place.'
  • 57. 'And you shall have it. I am ready to go on,' answered Tom. 'First let me pay you for your trouble.' The man took the money hurriedly, and Tom turned aside to where he had left Snow-queen, and vaulted into the saddle. He had scarcely done so before the foremost of the troop of horsemen that were clattering through the village came up with him and seized his bridle-rein. 'What do you want with me?' said Tom, trying to free himself. In a trice two or three more rode up, and he found himself surrounded. 'Now, then,' he cried out, angrily. 'What is the meaning of this?' 'Our lady, the Ranee, would have speech with you, sir stranger,' said the first of the troop. 'Where is she; and what does she mean by stopping a peaceful traveller?' 'You are alone. She has armed men at her back,' said the horseman cynically. 'But she means you no hurt. You had better come quietly.' 'Loose my bridle-rein, then,' cried the young rajah. 'And you,' to the two or three ragged-looking figures that were crowding about him, 'fall back!' They obeyed and he went forward slowly, with all the dignity he could command. Had he seen any chance of escape, he would have given a touch to Snow-queen, and in a few moments she would have shown them a clean pair of heels. But he was not in open ground; he was in the long straggling street of the village, with horsemen in front of him and horsemen behind, and there was no possibility of getting away. Wit, he felt, must serve him for strength, and if, as these men had said, their leader was really a woman, he did not doubt that he would be able so far to humour her as to be allowed to proceed.
  • 58. Presently he lifted up his eyes and saw her. She was in the midst of the cavalcade, borne in an open palanquin, and covered from head to foot in a saree of black gauze richly spangled with gold. As he approached, the men-at-arms who accompanied her separating to right and left to let him pass, she ordered her bearers to stop. Tom drew up in front of her and made a low salute. He could not discern the features of the lady's face; but he saw enough to make him sure that she was not the Ranee of Jhansi. A few seconds passed. He would not speak until she addressed him; he sat with head bowed humbly, after the Oriental fashion, while the piercing eyes behind the black and gold saree looked him through and through. Then came a curious and unexpected shock. She was speaking. He thought, at least, that she was speaking; but he could not be quite sure that his senses had not deceived him. For this high, clear voice, winged, to his fancy, with mockery, was not, certainly, the voice of one of the daughters of the land. Yet the language was the supple Urdu that the educated natives use. 'Who are you, sir stranger? And what brings you to our dominions?' she said. He gave an involuntary start, then answered, bowing low, 'Were it not that the whole world is under the dominion of beauty, I might ask my gracious lady her right to stop the traveller on his journey. As it is, I bow to her will. I am a kinsman of the Ranee of Jhansi, and I go in hot haste to confer with her on the strange portents of the time.' From behind the saree came a sound like the repressed gurgle of laughter; but it was stopped instantly, and the high, disdainful voice went on. 'I believe that you are lying, sir stranger; but the truth of your saying shall be proved. We, too, propose to visit our sister of Jhansi. Remain you with our escort, and we will take you in with us. If you are really what you profess to be, the delay will be of no account to you, and you may save your skin.'
  • 59. 'My skin is not of so much account to me that, for its sake, I should neglect my duty. The business on which I have come is urgent, and I cannot delay. Will your Highness permit me to take my leave?' There was another suppressed gurgle. He could have sworn, moreover, that from under the black and gold gauze there came a little English 'No'; but in the next moment he thought that his fancy must have been playing tricks with him, for the veiled lady was speaking in stern, slow accents. 'I will not permit you to leave us. Fall back, and take your place amongst my men.' 'Your Highness——' 'Silence! I have listened to you long enough. Abdul, seize his bridle- rein. If he resists, dismount him, and bring him on foot.' Seeing that there was, for the moment, no possibility of successful resistance, Tom fell back amongst the escort, who, so long as he walked on with them quietly, did not seem disposed to show him any violence. The headman of the village came out, meanwhile, to meet them, bringing provisions, and laying himself and all he possessed at the feet of the Ranee. She accepted his homage, but did not deign to speak to him, and, after halting for a few moments, she ordered her bearers and escort to proceed. Tom had been longing to leave the village, for he thought that, on the open ground, he might easily escape; but he found himself so closely watched, that no such effort was practicable. Reluctantly he made up his mind to wait until the night. He had gone over this ground before, making himself well acquainted with the bearings of the country, and when, soon after leaving the village, the leaders of the cavalcade swung round to the left, he knew perfectly well that they were going away from Jhansi, and not towards it. This he said to Abdul, but he was vouchsafed no answer. Tired and irritated, wondering what was to be the end of
  • 60. this strange adventure, and blaming himself bitterly for having halted when he was almost within a stone's throw of his goal, he went on the way he was led. It was afternoon when the veiled lady met him, and they tramped on until nightfall. By this time, so far as Tom, who had begun to lose his bearings, could judge, they were many miles distant from Jhansi. They encamped in open ground, there being no village or grove of trees at hand. A tent was pitched for the lady, who had been travelling for some time with the curtains of her palanquin closed. Tom, who felt that she was dealing treacherously with him, and who was haunted, moreover, by a bewildering suspicion that she was something very different from what she gave herself out to be, made an effort, when the cavalcade halted, to spring forward from his place in the rear, that he might speak to her, or at least catch a glimpse of her figure; but the fierce and burly Abdul placed himself in front of him. The vigilance of this man had never for one moment faltered, and it was evident to Tom that he was keeping up the other men to their duty of watchfulness. Thinking it well to appear submissive, he dismounted with the rest of the horsemen, tethered and fed Snow-queen, and joined one of the groups that were assembled round the little fires that had been lighted to cook the men's evening meal. A place was made for him, and he was given a supper of chupatties and dal, which, as he was simulating the manners of a person of high rank, he received in his own bowl, retiring a few yards distant from his attendants to eat it. Then he returned to the spot where he had left Snow-queen, wrapped himself up in his chuddah, and, with his back propped against the tree to which she was tethered, fell into a deep sleep. Tom was one of those favoured mortals who have the gift of sleep. No matter how anxious and harassed he might have been in the daytime, night always brought him peace and refreshment. Afterwards he thought of it as a strange thing. Here he was alone in
  • 61. the midst of strangers. What they wanted with him he did not know; but he knew full well that he had upon his person what, if they discovered it, would tempt their cupidity past any reasonable limit of endurance; he knew also that he had a great stake to fight for, and a hard problem to solve, and yet he slept—slept as peacefully as if he had been in his own little room in the cottage that looked down upon the silver Thames. Two hours passed away. His attendants had looked at him several times, and, at last, being satisfied of his perfect unconsciousness, they had followed his example, and now no one but Abdul was awake. Abdul had received his orders. He was to watch over the prisoner, but not to molest him in any way; he knew very well that, if he were detected in any attempt at outrage or robbery, he would pay the forfeit of his life for the crime; but the stillness of the moment and the perfect unconsciousness of the sleeping man were too much for his prudence. He would not hurt him. That would be to betray himself; but he would cautiously feel about him to see if he had valuables concealed in his sash or turban. If he had not, no harm was done. If he had, and if Abdul purloined them, then Abdul would be so much the richer, and the high-born youth, who would not venture, surrounded as he was by hostile strangers, to make any ado about his loss, would be the poorer. And that would be all. Thinking thus he crept closer to Tom, and, having softly drawn his chuddah aside began to finger his fine satin tunic. Once or twice the sleeping youth stirred, and then the robber drew back, but supposing himself in a dream, he settled down again, and Abdul went on with his work. The heart of the robber was jubilant and his fingers were light, for he was sure now that there was gold in the youth's waistband, gold which would soon be transferred to his own. The gold was almost within his grasp, he heard its jingle, his long fingers swept it, as they moved to and fro. Why then did he stop suddenly and draw back? Had he seen the youth's breast and shoulders white in the moonlight, and did he recognise him as one
  • 62. of the hated race, whom, in a few short weeks, the children of the Prophet would scatter and slay? But this should have given him courage, for he knew very well that he had but to say that a Feringhee spy had entered the camp, and the youth whom he purposed to rob would have his lips sealed effectually. Surely it was something more that stayed Abdul's hand. And, in that moment's pause, his prey escaped him. Strong, and with all his wits about him, Tom awoke; seeing his chuddah and tunic open, and Abdul glaring at him, like a startled wild animal, he sprang to his feet and struck out with the dagger which he carried in his belt. At the same moment the robber was smitten from behind. As, with a muttered cry, he fell to the ground, a voice broke upon the stillness of the camp: 'So the White Ranee punishes treachery. Let all take notice and beware!' CHAPTER XXIII THE SNAKE-CHARMER AND THE VEILED LADY As for Tom, he laid himself down again, not to sleep this time, but to watch. There was, however, no further alarm, nor, when, long before dawn, the camp began to stir and the morning fires were lighted, was any remark made with regard to the incident of the night. A narrow trench was dug; the robber was laid in it, and, once more, the cavalcade moved forward. Throughout that day they went on steadily. The prisoner was continually on the alert, but he was given no chance either of escaping or of speaking to the veiled lady in the litter. His passionate irritation over the delay grew, meanwhile, to such a height, that he was on the point once or twice of making some mad effort that would have had the effect of either seriously jeopardising his life or putting fetters on his limbs. That he restrained himself was due not so much to prudence as to fatality.
  • 63. He could never find a moment when his will-power and his surroundings leapt together. When he might have acted he could not. When all his nerves were braced and the blood coursed like fire about his heart, something would always happen to make action impossible. So, with throbbing brain and a heart as heavy as lead, he travelled on. Every hour was taking them further away from Jhansi, and nearer Gumilcund, although they were not shaping their course directly for the last-named city. The men were reticent before him, but he gathered from a stray word here and there that they were themselves uncertain about their movements, which would depend upon the result of an enterprise undertaken by some of their comrades. Towards mid-day they halted, and a man, who appeared to be a moulvie, or priest, joined them, was admitted to the tent, and held a conference with the lady, travelling on with the cavalcade as far as the next village, where he took his leave. What news he brought Tom did not hear, but he judged from the jubilant faces of the men, and the laughter and rude jests, some of which made his blood curdle, that there had been another triumph over the Europeans, and that these men were expecting to share in its results.
  • 64. Evening came and they halted again. It was in the neighbourhood of a large village, to the right of which stretched a mere or shallow pond, half covered with red pond-weed and overshadowed with some fine acacia and fig trees. By order of the lady in the litter, her tent, which always formed the centre of the camp, was pitched on the shores of the mere, being separated from the village by its waters. Immediately the men unsaddled, tethered and fed their horses, and lighted their evening fires. The villagers, meanwhile, who were hiding behind every tree and angle of wall, having satisfied themselves that those in camp had no hostile intentions, poled themselves over the mere in flat-bottomed boats, bringing with them fruit and vegetables, and grain and milk, so that presently the camp was like a fair. Sitting by the mere, and listening absently to the jabber and turmoil of the camp, where buying and selling and wrangling and gossiping were going briskly forward, Tom watched the curious scene. He was trying to devise some scheme either of escape or of making his situation known to Chunder Singh, when, suddenly, and in obedience to no act of volition of his own, so at least it seemed to himself, the current of his thought changed. It darted upon him with the force of an electric current that the scene upon which he was gazing was not new. The livid sky behind the mud walls of the village, the blood-red pavement at his feet, the fierce dark faces about him, surely, in some other life, he had seen them before. A moment more, and he remembered. He was living again over the strange night when all the conditions of his life were changed; his feet trod the banks of the stream that washed the gardens of his tranquil home; the dawn, the sweet dawn of an English June, was breaking, and the trees that he knew and loved were swaying to and fro over his head to the delicious breeze of the morning. Then he had seen this! It was his dream, his very dream; but not all! The effect upon his mind was overpowering. His strength, and the presence of mind, upon which he had always relied, seemed to be
  • 65. oozing away. Fate! Fate! and no hand of man was fighting against him! What could he do but submit? Shuddering, he covered his face with his hands. He must hide it away. He must forget. He must clear his mind from the stupefaction that was stealing over it, or all would be lost. But it was in vain, for, with his every effort, he seemed only to sink more deeply into despondency and bewilderment. Suddenly a sound came to him. It was as vivid to his sense as is the light of morning to the belated traveller—a voice clear and strong. 'Why,' it said, 'should this thing startle you? If a vision was granted to you, if you saw, beforehand, what would be in the future, and if now the vision is followed by what is, or appears to be, a reality, is that any reason why your strength and presence of mind should desert you?' A pause, and then, answering the thought of his heart, the voice went on, 'Fate! That is true. Everything is fate. But our resistances are predicted and foreseen as well as our trials. Arise and be of good cheer. This is no omen of evil, but rather of good. You say that the vision is not over. Again you are right. There is more to come, and in due time and place you will behold it; but tie not your limbs from present use in consideration of that which they may have to do in the future. In coming hither you have chosen rightly. She, like you, must "dree her dread"; but the Holy Ones love her, and will have her in Their keeping. Listen!' At this moment—it seemed a strange and incongruous thing—there broke in upon the eager spiritual colloquy a sound so ridiculously common and familiar that, uneasy as he was, Tom could almost have laughed. It was the discordant rattle with which, in India, a snake-charmer and conjuror calls his audience together. The sounds came from behind Tom. Turning in haste, he saw a hooded snake rearing up its ugly neck and head within a few feet of him. Behind the snake, sitting crouched together and eyeing him curiously, was an old man, with coal-black face, white hair, and supernaturally bright eyes. He was wrapped in a dirty white chuddah; a cloth, containing his implements of trade, lay outspread before him, and he held in his hand a light wand, with which he was directing the movements of the snake.
  • 66. When Tom turned he stopped his jabber for a moment to beg him not to be afraid, adding impressively that if he would only have patience, he would behold such a sight as he had never seen before. 'Others kill,' cried the old man, looking round on the soldiers who, pleased at any sort of fun, were crouching about him. 'They bring you a mongoose. There is a fight. The monster is killed. He lies stiff and stark before you. You clap your hands like silly children. But what is that? Nothing. I snap my fingers at them. No mongoose here, good sirs! No killing! I did not say no fight. Yes, you love fighting, and a fight you shall see! But a man will fight the monster; a man with his naked hands, and it shall be—not killed—but tamed! That is the true triumph, my masters—the true revenge! My enemy's blood, what is it? For a moment it fills my nostrils with its savour, in the next it is gone. But to tame him, to see him lie down at my feet and lick my hand, to spurn him once, and yet again; day after day to behold him grovel more deeply before me. This is joy! This is ecstasy! And it is this, in little, which I call you to behold.' He spoke in a high key, and with the most extraordinary rapidity, holding his wand, as he spoke, over the head of the cobra, which moved uneasily from side to side as if it were trying to escape from some fascinating influence. His voice dropped and there was a lull. The serpent gazed at him sleepily. He crooned a low song, which seemed to have a stupefying effect upon it, for it dropped and lay like dead. The soldiers, meantime, stirred to the entrails by his address, showed all the symptoms of intoxication; some rolling about in speechless ecstasy, others dancing, singing, and shouting, so that, in a few moments, the camp was changed into a field of demons. There came a cry from the snake-charmer. 'Give me room—room!' and, in the next instant, he had flung his wand aside, thrown off his chuddah, and leapt to his feet. At the same moment the serpent reared itself up, shot out its forked tongue, and threw its sinuous body at the man, who received it on his knotted arms. The hideous combat went on for some minutes. Now the man seemed to triumph and now the serpent. Tom was sick with loathing; but he could not
  • 67. turn away. An invincible fascination, helped by a suspicion that the combat had some mysterious importance for himself, kept his eyes fixed. Suddenly the silence of the camp was broken. There came a cry of, 'Give place! The Ranee is coming!' The combat was at its height—the man almost lost in the folds of the cobra, and the awe-stricken circle falling back—when Tom, who had kept his position near the snake-charmer, saw her come out. She was dressed in the brilliant robe of black and gold in which he had seen her first, and covered from head to foot, so that he could not see her face. With slow and dignified step she advanced towards them. She had crossed half the space that separated her from the snake. It had loosened itself from the man, and was turning in this new direction. Unable to restrain himself, Tom darted forward. 'Keep back!' he cried in English. 'You are mad!' She spread out her arms, waved him back imperiously, and moved forward. At the same moment Tom saw on the face of the snake- charmer a look of such anguish and dismay that he thought his enemy had conquered and given him a deadly wound. Yet the snake had dropped and was lying at his feet, not dead, but spent. Confused and troubled, Tom fell back. The lady was advancing still. She was within a few feet of the snake. Its master warned her back, but she took no heed of him. Then Tom, who could bear it no longer, turned away and covered his face with his hands. There was a moment of absolute silence. His heart beat with curious rapidity, there was a singing in his ears that almost deprived him of the power of hearing, and though feeling that this would be the time to get away, he seemed to lack the power to move a step. All at once there was a shout. It was followed by another, and then by another, 'Victory! victory! Our Ranee-jee, daughter of the Prophet, protected of Allah, has triumphed!' The cries rang through the camp, were taken up by those who clustered round it, and echoed back from the village, so that in a moment all the country seemed alive.
  • 68. At the sounds Tom turned, and this was the strange sight he saw. In the centre of the vast circle and at some little distance from the snake-charmer, who, recognising probably a master in his craft, had drawn back, and was now close at Tom's elbow, stood the Ranee. She stood with her head proudly raised, so that she looked taller than before. One little foot was planted firmly on the ground, the other rested on the neck of the cobra, which cowered before her as if smitten with sudden fear. But the strangest part of all was that the black and gold saree had been thrown back and that her face was exposed. With parted lips Tom gazed. It was the face of a little child, soft and white, with rose-red lips, and smiling eyes, in which the golden light of summer dawns seemed to be sleeping, and—if he was not mad—if he was not dreaming—he had seen it before. CHAPTER XXIV SUBDUL Tom's first idea was that she, like himself, was a prisoner, and he was about to commit the terrible imprudence of flinging himself at her feet, and begging her to accept his protection, when the snake- charmer passing him by, brushed him as if by accident, and pausing, made a low salaam, and breathed an apology. There was a look in his face which arrested Tom's attention; under cover of the clamour which had not ceased, he said in a low voice and in Marathi, which was known to his spies, 'Are you a friend?' 'I am his Highness's servant,' said the man, 'and I will help him to escape; but he must be prudent. The White Ranee is black of heart.' As he muttered the last words, speaking them in so low a tone that no one but Tom could hear, he was moving towards the Ranee. She greeted him with a smile of childlike triumph, and he prostrated himself at her feet. Then, resuming his wand, and singing his
  • 69. lullaby-song, he enticed the monster into its basket, while the Ranee, having looked round her proudly, threw the black and gold saree about her head, and returned to the tent. The snake-charmer began now to circulate among the soldiers. He was full of stories and jests, and wherever he went he was received with acclamations. Tom, who had taken up his station under the tree to which Snow- queen was tethered, watched him moving to and fro. Presently he noticed a strange thing. It was only as long as the snake-charmer was in the midst of each little group that its members were joyous or lively. As soon as he left them they became silent, most of them falling shortly into a heavy sleep. This must have been apparent to others besides himself, yet there were none who did not watch for and expect his coming. Night had fallen before he had made his round of the camp, and then all, with the exception of two sentinels outside the tent, were in a deep slumber. He crept now to the neighbourhood of Tom's station, and professed to curl himself up for sleep. The sentinels watched him drowsily. After a few minutes of perfect silence, one of them sat down and leaned his back against a tree. His comrade followed his example. They exchanged a few remarks to keep themselves awake. One drank from a bottle in his girdle and offered it to the other, whereupon their dropping remarks fell off into silence. And now no one in all the camp was awake but Tom and the snake-charmer. It was nearing midnight, but the moon—which was on the wane, but which in this clear atmosphere diffuses a brilliant light—enabled them to see their way, and they both arose. 'Now is our time,' said the snake-charmer, chuckling. He was none other than Subdul, Snow-queen's groom. 'Are you sure they are well settled?' said his master. 'I have given them bhang, Highness. That, and the excitement of the evening, will make them sleep like the dead; no noise will awake them. But the nights are short; why does my master linger?'
  • 70. 'Are you sure she is not a prisoner, Subdul? Might she not come with us if we told her our design?' 'If my master means the Ranee, I tell him that she is black—black at heart and false of speech. Let not my master trust her.' 'What do you know of her, Subdul?' 'I know what these have told me. Does my lord know Dost Ali Khan?' 'The adopted son of the rajah of that name?' cried Tom, with some excitement; 'why, I entertained him once. I have now a pass from him about me. Has he anything to do in this?' 'He has everything to do. He is the hope of thousands. They crowd round him as their lord. If my master has won Dost Ali Khan's favour he is lucky. This man, my lord, this so-called prince, has, as I hear, persuaded the White Ranee to join herself to him. She was married to an English sahib, and she saw him slain. She looked on at the slaughter of her countrymen and women, and now, in her new lord's name, she is taking command of the murderers. If my master wants any more proof that she is a traitress——' 'Silence, Subdul! She is coming!' 'Master! master!' cried the man in strong excitement, 'now is the time to fly!' 'I must let her speak to me first.' 'No, no; let my master listen to me! She is a witch; she will enslave him.' 'Nonsense, Subdul; I know her, I tell you. Be silent!' murmured Tom, whose heart was beating strangely. And all this time the White Ranee, with veil thrown back, and face looking pure and spiritual in the moonlight, was making her way quietly through the sleepers of the camp towards the spot where Tom was standing. They were alone now, Subdul having disappeared. Tom did not move, for a spell seemed to be over him;
  • 71. so she went close to him and laid her hand on his arm. Then a sudden trembling seized him. 'Who are you?' he said, in a low voice. 'Surely you know me,' she answered. 'I know you, Tom Gregory. Why did you run away from Delhi without seeing me again?' 'Why are you here?' he said sternly. 'You are impolite, my dear boy. A question should be answered.' 'This is no time or place for amenities, and you know it. Answer me! Are you a prisoner? For if so I will take you away with me and protect you honourably until I can restore you to your own people. If you are not a prisoner—if you have given yourself up to the enemies of your race, then I will leave you to reap your own punishment.' The lady laughed. 'So stern all of a sudden!' she said. 'You are playing with me. You are wasting time.' 'Time was made for slaves, Tom,' said the lady, in a sweet girlish treble, 'and I am not a slave; neither are you. Sit down under this tree, and let us talk together quietly. Ah! how pleasant it is to speak to an Englishman again!' 'Vivien! are you mad?' 'Yes, I am mad, always mad, Tom; but madder than ever now. Be mad with me; you have no idea how delightful it is to live in a dream!' 'The dream will soon be over, my poor child. Do you think that you can tame men as you tame serpents?' 'Think? I am sure of it, Tom!' 'Then, if this is your dream, for heaven's sake awake! Good God! why do you look at me so?' cried the young fellow, in a sudden transport. She was standing before him in the moonlight, her golden hair blown this way and that way with the wind, her eyes full of laughter,
  • 72. an expression half-mocking, half-pitiful, playing about her lips. 'Do you know how awful this time is?' he said. 'Are you human?' She laughed. 'No,' she said, 'I don't think I am. Take my advice, Tom, and be inhuman too!' 'Vivien, you are playing with me!' 'Of course I am; I never do anything but play. I played with you, and if it had not been for Grace Elton, who is a very serious young person, I should have won you over as a playfellow. I played with Charlie Doncaster, poor boy! But he had not my animal spirits, and he was beginning to be grave and tiresome when—but I don't want to talk of disagreeable things. Well! The next was his Royal or Imperial Highness, Dost Ali Khan. I wonder, by the bye, if you remember him. I was within an ace of running over him in the streets of Delhi. It would have been a good thing for some people if I had succeeded. You saved him, didn't you? Set that as a make- weight against all your good deeds, Mr. Tom, and see what the result will be! But to return, as the story-tellers say. I was so much amused with his Highness that I took the trouble to cultivate him; and it was a very funny little episode, I can assure you. Heavens! how he hated me at first! I tell him sometimes that I am surprised he did not kill me, for I gave him heaps and heaps of chances. He let me live, however, against his better judgment, I believe, and now he is my slave. I can do whatever I like with him. What do you say to that for a game?' 'I say that you are mad—that you don't know what you are saying, and the night is passing. No more of this folly! Will you come with me or will you not?' 'Tom, what a baby you are! Never mind, I like you so! But be a wise baby if you can, and listen to me quietly. I am not going with you. It would be absurd to begin with, and highly dangerous, all through. On the other hand, having found you, I don't mean to let you slip out of my fingers. So you must come with me. I must tell you that you have been so fortunate as to make Dost Ali Khan, his Imperial
  • 73. Highness of the future, your friend. He is the great man just now, for he is the only person in this part of the world who knows what he wants, so the rest of them look up to him. The soldiers, banded and disbanded, the native states, the fanatics of the towns, they are all waiting for his signal. When he gives it—Heavens! I begin to feel sane, as I think of it—what a conflagration there will be! However, that is beside the present question'—she stopped to laugh. 'I think I am speaking rather weightily,' she said; 'don't you? Now, to go on in the same strain, this exalted personage, whose ally I am, offers you his friendship. He doesn't wish you to fight for or with him, for he believes you would say "No," and he has a sort of conscience about destroying you. What he asks is that you will take me into Gumilcund—think of the magnanimity of it!—and keep me there until the explosion is over. Then, if the world doesn't meanwhile fall in ruins about us, we can decide about the future.' She paused and went a little closer to him. A cloud had veiled the face of the moon so that, near as she was, he could only see her indistinctly; but he felt her—felt her in every nerve of his being, and for a moment he hesitated. Why should he not, after all, take her back to Gumilcund first, and leave her there in safety before setting forth on any other mission of rescue? He did not believe all she had told him. Either she was mad—as she said of herself—and in that case she ought to be protected from the results of her own mad actions; or else she was playing with him. Yes, she had herself spoken the word. But was she accountable for her own strange nature? Should she be punished because she could not see the awful realities that lay about her? Since, by some strange freak of fortune, she had been able so far to gain protection, was he to deny her the asylum that would make her safety sure? While he reasoned with himself she stood by him. She did not speak, she did not stir; but as the silence prolonged itself a sigh, soft as the breath of a sleeping child, escaped her lips. 'Vivien!' he said tremulously, 'is that you?'
  • 74. 'Yes, it is I; I am near you. You will come with me, Tom?' she murmured; and, in low caressing tones, 'Dearest Tom!' 'Why do you say that?' he said, hoarsely. 'Listen to him, poor child!' she cried. 'Why? Can't you tell? Can't you imagine?' 'You are false!' he groaned; 'you have said it of yourself!' 'False to others, Tom; never to you!' 'False to one is false to all.' 'Listen to him!' she cried again. 'What an exalted standard! But, my young king, let me tell you that you are ungrateful and unjust. If I could only save you by being false to others; if every subterfuge, from the beginning, was planned for this—that I might have you; that I might hold your life in my hands—what then?' 'Is it so?' he said hoarsely. 'You see!' she cried; 'you were cold because you did not understand!' At this moment, when his will was passing away from him, and his heart was as wax in the midst of his body, there came a strange and sudden disturbance. Subdul Khan had been crouching behind them; his ear was to the ground, and all his senses were on the alert, for he feared treachery. Whether he did actually hear in the distance the rumble of gun-carriages and the sound of armed men on the march, or whether he merely professed to hear them to arouse his master, cannot be certainly known; but the effect was the same. Suddenly, with a cry of, 'The rebels are upon us!' he sprang to his feet. Snow-queen was saddled, and so was the horse of Subdul Khan. They mounted them together, and while Vivien, with a ringing cry, to which none of the besotted men about her paid any heed, ran frantically through the camp, Snow-queen and her master, going like the wind, disappeared in the distance.
  • 75. CHAPTER XXV AN AWFUL RIDE AND A RESCUE Hurry on, brave men! let the wind be your messenger; stop neither to eat nor drink; through the long sultry day and at nightfall, when the awful eye of day is closed and the stars come out pale and languid overhead, even until morning dawns and the terrible round of sweltering heat and blinding dust begins again—hurry on! By narrow and unfrequented ways, through villages whose favour has been bought, under the shade of trees, and across tracts of jungle, where you are obliged to go at a foot-pace, giving breathing time to the gallant beasts that have carried you so bravely—on and ever on, for two dreadful days and nights, that to one of you seem ever afterwards like an awful dream. And yet, you are too late. And well it may be for yourselves that you did not arrive earlier. For the storm has broken. In fire, and blood, and fever it is spreading from city to city, and Jhansi, the home and citadel of a woman scorned, has caught the dread contagion. Up to June 1 they were at peace. The Ranee still sat smiling in her palace, and still she added to her body-guard persons of proved loyalty, and still the English believed her promises, and still the troops within the city proclaimed their faithfulness loudly. And why did the English need to fear? Meerut had not moved them. Delhi had not moved them. The native states, Gwalior and Gumilcund, and Rewah and Banda, were holding their hands. Nay, it was known that some of them had offered help to the Paramount Power in the re- establishment of order; and even if they had feared, what could they do? To show mistrust at this eleventh hour would be to undo all that had gone before, and to ruin everything. On June 3 mysterious fires broke out; but even these did not unduly alarm them. They were attributed to accident. It was not until the 4th that their eyes were opened. Then the soldiers on parade, breaking away suddenly and causelessly as it appeared to those who had not heard of the secret messages that had been passing
  • 76. between the palace and the native lines, shot down their sergeant and seized the artillery, and with it made their way to the fort within the native city. The Ranee still sat smiling in her palace; but when the news came to her she ordered the palace gates to be opened, mounted her horse and cantered over to the lines with her own faithful body-guard, who in her name had seized upon the treasury, behind her. Some of the English officers had been hurrying to her palace. They were told on the way that she was in the hands of the mutineers, and instantly the full magnitude of what had happened darted upon them. They dashed back to the cantonments, calling as they went on the English and Eurasians to follow them into the Star Fort, the only building belonging to them now that was capable of defence. It all happened in a moment. Some of them had not even heard of the disturbance on parade. In the little house, once a tomb on the maidan, something had been seen; but no one clearly understood what had happened. 'Father will be in presently, and then we shall hear,' said Mrs. White to her little Aglaia, as she tried to soothe her off to sleep. But then the ayah rushed in like a wild creature, and with a cry of 'They are coming; hide!' tore the child out of her arms. She knew little more. Some one came and dragged her out of the house, and she was mounted on a horse, to which, crying out for her child, she clung because she could not help herself, and there was a mad, sick flight across the blaze of the maidan, with yells at her heels, which seemed to recede as she flew on, and then all at once she was in the Fort amongst a circle of frightened women, and her husband, who had not come for her himself, having work to do, was with the men, but her child—her little darling—was nowhere to be seen. She made a wild rush for the door. Even amongst the rebels there must be some one who would have mercy upon her. When they held her back by force her shrieks and cries were piteous to hear. But all were not so helpless. In the little spell of time given them by the rebels who were quarrelling over the booty, the men looked up