My understanding is that it was common in the 1840s and 1850s. People say it goes back to Andrew Jackson's era, or less often and more questionably to Thomas Jefferson's. I assume it wasn't used as much after the Civil War, but here is an 1868 Atlantic article that uses the phrase.
You can also check Google Ngrams. The phrase took off in the 1830s, fell sharply from a peak in 1857 to a trough in 1864, and then climbed up again in the 1870s and 1880s. At some point, "the Democracy" ceased to mean the Democratic Party, but I don't know when.
Hmmmm the Ngrams graph shows the term "the democracy" was used as much in 1800 as it is today, but does not tell us what it referred to then or now.
Wikipedia tells us "the democracy" referred to Jacksonian Democrats, but no details on when or why first used.
No other search I can think of produces more information.
Ah well...