The Database Connector available in the Mendix Marketplace can be used to run SQL actions on any database you are using. The database connector supports queries as well as actions like updates, deletes, and stored procedure calls.
Right out of the box, the data grid widget enables you to provide an Excel export of the data displayed in a data grid to your application users. For the bulk import or export of data in the Excel format, you can use the following two Mendix Marketplace modules:
- Excel Importer – This module allows you to define templates for the different Excel sheets you want to import. A template defines the data provided in a sheet as well as how it should be mapped and converted to the entities defined in your Mendix application. You can reuse these templates if you regularly upload the same sheets with updated data.
- Excel Exporter – This module allows you to define templates for how you want to export data from your Mendix application as an Excel sheet. Using these templates, you can regularly export data in the exact same formatted Excel sheet. For more information, see How to Use the Excel Exporter in the Mendix Studio Pro How-to’s.
The Mendix Marketplace contains multiple modules that can help you import or export CSV-formatted data:
- Excel Export – This module also supports exporting to the CSV format.
- Flat & Delimited File Import – This module allows you to import flat and delimited files (CSV) from configuration in the runtime only, relieving you of the Java work.
- Flat & Delimited File Export – This module makes exporting fixed length and delimited files (CSV) easy, as it handles all the Java coding and allows you to easily export your data from a microflow.
- Simple CSV Exporter – This module is used for exporting to CSV from a microflow.
- CSV Services – This module is the easiest and fastest way to get Excel data in and out of Mendix applications. It creates a REST endpoint for every entity in your application, allowing you to upload and download data in comma-separated values format. It also provides microflow actions for importing and exporting CSV in microflows.
How Can I Import & Export Fixed-Length & Delimited Files?
Some of the modules above support fixed-length and delimited files.
If you cannot find a module with support for your specific fixed-length format, using the Mendix Connector Kit to create a custom microflow action to handle import and export may be an option. For more info on the Connector Kit and Mendix Java APIs to provide microflow extensions, see the section How Can I Extend the Functionality of the Mendix Platform? in Extensibility.
There are a number of ways you can mass export and import data from your Mendix applications:
- Custom build services – Examples of this are using web services or REST services. The benefit of this approach is that it enables you to adapt the data and validate it complies with your business rules.
- Backup and restore – You can use custom (SQL) scripts to fill a Mendix development database with the data you need. When done, you create a backup of this database and restore it in the desired destination database.
- Source database – When you start a runtime on a new empty database, you can specify that it needs to be initialized with data from another database.
If you want to create a real-time mass synchronization between two environments, you can use entity event listeners. This enables you to run custom Java logic for every object event (for example, when data is changed in your database). In this custom handler, you can provide logic to duplicate the data changes to another app.