Run a CommCare Export
Once you have all the components ready, you can run the commcare-export command.
Components needed to run the DET:
The DET installed on your computer (link to installation instructions)
A project space with an application that contains data.
A query file for the DET to tell it what data to export.
The Necessary credentials for CommCare HQ (Username and API key)
If exporting to a database, the necessary credentials for the database you choose to use.
Optional commcare-export flags
For a full list of flags, you can run commcare-export --help
argument | possible values |
--since | Provide the DATE value in YYYY-MM-DD format. This will export all data after this date. |
--until | Provide the DATE value in YYYY-MM-DD format. This will export all data before this date. |
--verbose | Includes a more detailed output to the user. |
--verbose 2> logs.txt | This flag exports log files to a text file. |
--verbose 2>> logs.txt | Append logs to an already existing log file. |
--missing-value | Override the default value (null) that is used whenever data is missing from the form/case. |
--api-version | Specify the version of the CommCare API to use for exports. Defaults to v0.5. |
--start-over | Ignore any checkpoints that may exists and re-export ALL data. |
--strict-types | This won’t allow changing column types once they are created when saving to a SQL database. |
--version | Output the version of commcare-export that you're using (useful for debugging). |
--auth-mode | Use "digest" auth, or "apikey" auth (for two factor enabled domains). |
Tips:
OUTPUT-FORMAT refers to the format in which you want to export the data.
YOUR_PROJECT refers to the name of your project space, not the entire domain URL. For instance, the URL would be https://www.commcarehq.org/a/YOUR_PROJECT. For the tool, type in YOUR_PROJECT.
If you are using a domain that isn't stored on www.commcarehq.org, then you will need to use the "--commcare-hq YOUR_URL" flag in the command prompt.
YOUR-QUERY_FILE_NAME.xlsx refers to your query file that is saved in the scripts folder of your Python installation.
YOUR_OUTPUT_FILE_NAME.xlsx refers to the file that will contain the exported data. This file will also be saved in the scripts folder of your Python installation.
Export using Windows
Run the following commands in your command line interpreter to export data from CommCare HQ:
Markdown
C:\Python39\Scripts>commcare-export --output-format markdown --project YOUR_PROJECT --query YOUR_QUERY_FILE_NAME.xlsx
Excel
C:\Python39\Scripts>commcare-export --output-format xlsx --output YOUR_OUTPUT_FILE_NAME.xlsx --project YOUR_PROJECT --query YOUR_QUERY_FILE_NAME.xlsx --username username@email.com --auth-mode apikey --password ***********YOUR_API_KEY**************
Database
C:\Python39\Scripts>commcare-export --output-format sql --output DATABASE_URL --project YOUR_PROJECT --query YOUR_QUERY_FILE_NAME.xlsx
Export using MacOS
Run the following commands in your command line interpreter to export data from CommCare HQ:
Markdown
Excel
Database
Export using Linux
Run the following commands in your command line interpreter to export data from CommCare HQ:
Markdown
Excel
Database