Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Last active August 29, 2015 14:20
Show Gist options
  • Save matthewpoer/7beaa4461b5ac42f2220 to your computer and use it in GitHub Desktop.
Save matthewpoer/7beaa4461b5ac42f2220 to your computer and use it in GitHub Desktop.
Convert the HTML table from a fields_meta_data table dump into a SQL statement to create the table on your work station

Turn HTML fields_meta_data dumps into SQL statements

(1) Manually remove

and open/end tags

(2) remove all strings matching class="tabDetailViewD\w"

(3) replace   with NULL

(4) replace <tr> with \n\(

(5) replace </tr> with \),

(6) replace <td> with '

(7) replace </td> with ',

(8) replace 'NULL' with NULL

(9) replace ,\), with \),

(10) manually remove the top one or two lines of blank space and table headers

(11) replace \('\d+', with \(

(12) manually replace trailing , with ; on the last line

(13) prepend the following truncate and INSERT statement...

truncate fields_meta_data;

insert into fields_meta_data(
id, name, vname, comments, help, custom_module, type, len, required, default_value, date_modified,
deleted, audited, massupdate, duplicate_merge, reportable, importable, ext1, ext2, ext3, ext4
)
values
@bickart
Copy link

bickart commented May 4, 2015

Why don't you write a PHP program to upload a file and have it generate the .sql?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment