Skip to content

Importing Data to Backendless

Importing data into a Backendless backend can be done either with the Backendless console or using the Management REST API. The import feature can process the following types of data:

  • Application Settings - includes application configuration, which includes email configuration, mobile and social settings, development team setup, external hosts and git config.
  • Table Schema and Data - includes schema definition, column types (optional), data objects and relations between the objects.
  • Geo Categories and Geo Points - includes geo points and the categories they belong to.
  • Export from Parse - imports data exported from Parse

The import feature is available in Backendless console under Manage > Import:

manage-import-screen.zoom50

Importing Application Settings

The App Settings section accepts a file in the JSON format. The best way to become familiar with the file format is to run Export for an application and see the structure of the settings.json file.

Importing into Data Service

This section accepts one or more files in the JSON or the CSV formats. Each file corresponds to a single table. If the table does not exist, it will be created with the same name as the name of the file. A file may either contain only schema definition (columns and their types) or both schema definition and the objects. Consider a file called Product.csv with the following data:

price
productName
599
iPhone
899
Surface Pro
399
XBOX One
1200
MacBook
price,productName  
599,iPhone  
899,Surface Pro  
399,XBOX One  
1200,MacBook

To import the data into the application click the add file button next to Data Service and locate the file. Notice that the first line in the file contains the names of the columns and there is no additional information about the column types. As a result, when you click the Import button, Backendless console shows the following screen for each CSV file:

import-changing-data-type.zoom50

The user interface lets you select a data type for each column. If more than one CSV file is imported, a similar form is displayed for each file. Once the types have been selected, click the Finalize Import button. Backendless processes data import as an independent, asynchronous task. Depending on the size of the imported data, it may take some time for the import to complete. Once it is finished, Backendless sends an email with the import status/log to the email address associated with the application.

For the file shown above, the imported data in Backendless will appear in the Data section of the console:

imported-product-table.zoom50

Notice that Backendless added the objectId column with unique values assigned to each record and also added the created and updated columns. It is also possible for your objects/records to use custom IDs. The column name must be called objectId and it must contain unique values. For example:

price
productName
objectId
599
iPhone
1
899
Surface Pro
2
399
XBOX One
3
1200
MacBook
4
price,productName,objectId  
599,iPhone,1  
899,Surface Pro,2  
399,XBOX One,3  
1200,MacBook,4

Data Types

Backendless supports a special format for the header row with column names and data types. The format for defining the data type for a column in the header row is:

columnName(type)

where type can be any of the following values:

  • STRING_ID - applies only to the objectId column, indicates that the values are unique IDs identifying objects.
  • STRING - a string value with the length of no more than 500 bytes.
  • TEXT - a string value with the length of no more than 3000 bytes - these values are placed in a special storage and are not optimized for fast searches.
  • INT - 4 bytes, numeric value in the range between a minimum value of -231 and a maximum value of 231-1.
  • DOUBLE - double-precision numeric value with an allowable range of -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308
  • BOOLEAN - a three state boolean value allowing values of true, false and null.
  • DATETIME - a date/time value in the following format: mm/dd/yyyy hh:mm:ss GMT+offset. The time and the timezone components of the value are optional. If the timezone is not specified, the imported date value is handled as GMT+0 date/time.

For example, the following header row declares columns and pre-assigns data types to them:

"objectId(STRING_ID)", "name(STRING)", "price(INT)", "desc(TEXT)","date(DATETIME)","discounted(BOOLEAN)"

When the types are specified, Backendless still shows the second step of the data import - the screen where the developer can adjust the data types for the columns.

Relations

Backendless can import related objects and reconstruct relations between them. The system uses a special naming convention for the columns representing relations. There are two types of relations supported by the system: one-to-one and one-to-many.

One-to-one Relations

For one-to-one relations. the column must be defined in the "parent" file - the file containing objects/records which reference other related entities. For instance, suppose there are two files in the import - Order and Customer. The "order" records contain a column referencing a "customer" record. In this case, Order.csv would contain a column which references related objects from Customer.csv. The value of a reference must be the objectId value of the related record.

The format of the column name defining a relation is significant. It includes column name, name of the file containing related entities and a special marker designating the column as a relation. The general format of the column name is:

columnName__Filename__bcklsFK__ONE_TO_ONE

Using the same example of Order and Customer, the files would look as shown below:

Order.csv:

objectId
name
customer__Customer__bcklsFK__ONE_TO_ONE
1
Office Supplies
1
2
Catering
2
objectId,name,customer__Customer__bcklsFK__ONE_TO_ONE  
1,Office Supplies,1  
2,Catering,2

Customer.csv:

objectId
name
1
AcmeFoo Corp
2
AcmeBar Corp
objectId,name  
1,AcmeFoo Corp  
2,AcmeBar Corp

When importing files with related records, Backendless recognizes relations and displays them accordingly on the second step of the data import - the screen where the column types can be set or adjusted. Notice how the relation displays for the sample data shown above:

importing-relations.zoom77

Once the import is complete, the Data browser automatically displays all relations as links:

related-data-after-import.zoom61

One-to-many Relations

One-to-many relations differ from one-to-one in a way that the relationship column is defined at the child level. For example, consider a scenario where an Order object contains a collection of OrderItem objects. In this case, the relation column must be defined in the OrderItem.csv file. Each OrderItem record contains a value of objectId of the Order record it belongs to.

The format of the column name defining a one-to-many relation consists of column name (in the parent object), name of the file containing parent entities and a special marker designating the column as a relation. The general format of the column name is:

columnName__Filename__bcklsFK__ONE_TO_MANY

Extending the example of Order and Customer shown above with the OrderItem.csv file:

Order.csv:

objectId
name
customer__Customer__bcklsFK__ONE_TO_ONE
1
Office Supplies
1
2
Catering
2

Customer.csv:

objectId
name
1
AcmeFoo Corp
2
AcmeBar Corp

OrderItem.csv:

objectId
name
items__Order__bcklsFK__ONE_TO_MANY
1
Pen
1
2
Pencil
1
3
Sandwich
2
4
Juice
2
objectId,name,items__Order__bcklsFK__ONE_TO_MANY  
1,Pen,1  
2,Pencil,1  
3,Sandwich,2  
4,Juice,2

When importing the files, notice how Backendless recognizes and confirms the relations in the second step of data import:

multiple-relations.zoom82

Importing into Geo Service

The Geo Service section of the Import page allows importing the geo points (in .csv file) or geo fences (in .json file). In the import file containing geo points, each row defines one geo point. A single row must have the following structure:

latitude, longitude, list of categories, metadata

where:

Argument                Description
latitude the latitude coordinate of a geo point expressed in decimal degrees (DDD). For example: 32.78306, 40.6501
longitude the longitude coordinate of a geo point expressed in decimal degrees (DDD). For example: -73.94958, -96.80667
list of coordinates comma separated list of categories the geo point belongs to. The value must be surrounded by double quotes. For example: "restaurants, points of interest".
metadata -

Consider the following example of a CSV file:

29.42412,-98.49363,"Businesses,PlacesToVisit","city=SAN ANTONIO|BusinessType=Restaurant|Rating=3.5"  
32.08088,34.78057,"Businesses,PlacesToUse","city=TEL AVIV|BusinessType=Hotel|Rating=5.0"

Once this data is imported to Backendless, the GeoLocation pagevisualizes them as:

imported-geopoints.zoom50

Import from Parse

The Import user interface provides a way to select a ZIP archive created by Parse's export. Backendless imports the following data from Parse's archive:

  • Users (password remain the same)
  • Data tables and objects
  • Data object relations
  • Files (Backendless copies files into Backendless File Service)

import-from-parse.zoom50