Skip to content

Instantly share code, notes, and snippets.

@jana007
Last active September 6, 2023 07:51
Show Gist options
  • Save jana007/ecdc156ae37418fa580e to your computer and use it in GitHub Desktop.
Save jana007/ecdc156ae37418fa580e to your computer and use it in GitHub Desktop.
How to remove Drupal webform submission data by node ID and submission ID via command line
log into mysql via whatever ssh client you're using
mysql -u 'username' - p
enter password
show databases (optional)
show satabases;
select db
use drupaldb;
show tables (if you want)
show tables;
view tables to get some info
select * from "table-id";
let's get more specific
select * from webfrom_submissions where nid=383;
In this example nid means "node ID".
An easy way to get this info is to go to the webfrom itself and click edit.
The node ID will apear in the URL
IE: https://webdev.odl.fsu.edu/users/user-name#overlay=node/383/webform-results
We want to remove reslts from certain times but unfortunately we can't read the submitted date!
Use an epoch time converter to make the time legible.
IE: 1452559548 = 1/11/2016, 7:45:48 PM
Go to the webpage and verify dates, this may take a bit of trial and error. This is how we will get the range of dates.
We want everything from 1421185871 and 1428501559 aka 1/13/2015, 4:51:11 PM and 4/8/2015, 9:59:19 AM
Now we know all the info we need to remove the unwanted webform data!
We needed:
database name
table name
nid
submitted time range
Putting it together:
delete from webform_submissions where nid=383 and submitted between 1421185871 and 1428501559;
You may have a database error if you just remove the submissions,
so you may have to go back do submission data as well
show tables;
---> | webform_submitted_data |
select * from webfrom_submitted_data;
OMG this is way too much data!!!!! Remember to narrow search results with WHERE
select * from webform_submitted_data where nid=383;
This data is more manageable but it's still a lot of data.
From here we can get the SID aka the submission ID.
Compare the list of SIDs on the website to know which data to remove.
IE: delete from webform_submitted_data where nid=383 and sid between 1333 and 1465;
Boom, you should be done. Please keep in mind PHPMyAdmi makes all of this way easier
but it is very important to know databse fundamentals if you want tobe a pro ^__________^
The other alternative is to remove each submission manually but....
WE HAVE COMPUTERS FOR A REASON. Command them!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment