CommCare Sync
CommCare Sync is a self-hosted, standalone, web-based app that can be used to manage a CommCare “data warehouse.” It’s a suite of configurations, with an improved UX from the command-line Data Export Tool. This turn-key tool allows you to export your data from CommCare and save it to a local or cloud-based database (MySQL, PostgresSQL, Amazon RDS, GCP Cloud SQL, Azure SQL Database).
Installation
If you wish to try out, or self-host CommCare Sync, you can do so by setting it up from the source code which is available in the commcare-sync Github repository.
For help installing and managed production environments you can follow the documentation of the commcare-sync ansible repository.
Note that Dimagi does not provide support for self-hosted environments. For any issues or questions on hosting, please post to the open source developer forums. If you want Dimagi help hosting CommCare Sync, you can contact our delivery team.
Functionality
This set of tools provides a user-friendly interface for administrators to set up their CommCare data pipeline. The functionality includes the ability to:
Automatically generate a Data Export Tool config file from CommCare.
Create project space(s) in CommCare Sync, connected to your CommCare project space(s) and your database(s)
Upload a DET config file that will automatically pull data from your CommCare project space to your database on a set schedule
Monitor your data syncs via CommCare Sync's log feature
Configuration Steps
Steps to configure CommCare Sync, as represented in the demo video:
In CommCare HQ Data page, create a form or case export
Download the DET config file
Open your Excel DET config file to see the fields from your export with the option of mapping specific data types. If you aren't transforming your data, there's no step needed here.
Open CommCare Sync, create a new account (instructions below)
Add a project by pasting your CommCare project space name
Add your database via the Admin Site (can be any available database)
Add an export from your new project, and add your database and your config file you downloaded in step 2
Run export. This applies the configuration file to do an initial sync of all the data from your CommCare project space.
View the log to see more info - like to confirm how much data was pulled in
Connect your BI tool of choice, and start exploring the data
Note for projects syncing data from multiple CommCare project spaces:
The process described above is for connecting a single CommCare project space. If you are connecting data from multiple CommCare project spaces, you need to add each project space as a Project in CommCare Sync (step 5), and repeat the process of downloading each DET config file per project space (step 2), to then each be uploaded to CommCare Sync (steps 7 & 8). (IMPORTANT: there is a new feature release that will allow applying the same DET config file to multiple project spaces in the CommCare sync tool).
Download your DET config file from CommCare
Download or create a Data Export Tool config file.
The easiest way to create these is to start with a normal export configuration on HQ and have it generated. See https://dimagi.atlassian.net/wiki/x/JCrKfw for more details.
Edit the DET file using the “best practices” below
Create a CommCare Sync account
Ask a site admin to create an account for you and share credentials, then change your password.
Sync your data
To sync data, follow the following steps:
If you haven’t already, add the CommCare project space in the “CommCare Setup” tab.
If you haven’t already, add a CommCare account that has access to the project space.
Important note to Dimagi users: Do NOT use your superuser @dimagi.com account, follow the steps below to create a user below. Create a web user for a specific project, and set up API key for that user (under Account Settings). You can use a "+" in your email address that tells you what your web user is for. e.g. "firstnamelastname+demo-cc-sync@dimagi.com"
Add the export from the “Exports” tab.
On the export details page, click “run”.
When the run completes, view the logs to confirm it ran successfully.
Data will be updated for all exports on a schedule (currently every 12 hours, managed by a system admin).
Data Export Tool Best Practices
Some recommendations for modifying the DET config files downloaded from HQ:
Double check the name of the sheet (tab) in your DET config workbook to be something specific to your project / case type. The tab's name, not the .xlsx file name, will be used as the table name in SQL. The default of “Cases” or “Forms” should not be used, but instead changed to e.g. “covid_19_index_cases”
Add a “str2date” mapping to any date properties and fields. This will make it easier to use them in various BI tools.
There is a subtle difference between the 'Extra Arguments' field in a CommCare Sync Export and a CommCare Data Export Tool parameter. If an argument in CommCare Sync takes multiple parameters ('since' and 'until,' for example) it must be formatted like: --until=2020-09-30
Adding Databases
Databases can be added by site admins by using the "databases" link in CommCare Sync sidebar navigation. The database may need to also be separately created by a system admin on the server.
Administration
System administration is documented in our production environment documentation.