48 | | INDEX 'reference' ('project','form','field'), |
49 | | KEY 'value_key' ('project','form','field','value'), |
50 | | KEY 'label_key' ('project','form','field','label'), |
51 | | FOREIGN KEY ('project') REFERENCES redcap_projects (project_name) |
52 | | ON UPDATE CASCADE, |
| 48 | INDEX reference (project,form,field), |
| 49 | KEY value_key (project,form,field,value), |
| 50 | KEY label_key (project,form,field,label) |
| 75 | |
| 76 | === Loading data into the table === |
| 77 | |
| 78 | If you have more than a couple of elements to add, use LOAD DATA LOCAL INFILE. This isn't entirely straightforward. |
| 79 | |
| 80 | Prepare the text file. Match up the columns and populate with the correct project, form and field names. Save it from excel as 'tab delimited text' (comma separated doesn't work because there are commas in the text. Then open it in an editor and remove any / all quote marks. Now upload to the server. |
| 81 | |
| 82 | Firstly, because it represents a security risk, you have to enable local loading, by starting your mysql client connection with the option " --local-infile". |
| 83 | |
| 84 | Secondly, from within mysql connection, do something like: |
| 85 | |
| 86 | {{{ |
| 87 | LOAD DATA LOCAL INFILE '/home/nick/sql_insert_medications.txt' INTO TABLE sql_fields |
| 88 | FIELDS TERMINATED BY '\t' |
| 89 | LINES TERMINATED BY '\n' |
| 90 | (id,project,form,field,value,label) |
| 91 | ; |
| 92 | }}} |
| 93 | |