Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program cloud development API database import


May 20, 2021 WeChat Mini Program Development Document



databaseMigrateImport

This interface should be called on the server side, as detailed in the service side API.

Database import

The request address

POST https://api.weixin.qq.com/tcb/databasemigrateimport?access_token=ACCESS_TOKEN

Request parameters

Property Type The default Required Description
access_token string Is The interface calls the credentials
Env string Is Cloud environment ID
collection_name string Is Import the action name
file_path string Is Import file path (import files need to be uploaded to the same environment storage, can be uploaded using developer tools or HTTP API upload file API)
file_type number Is Import file type, file format reference database import guide in the file format section
stop_on_error bool Is Whether to stop importing if an error is encountered
conflict_mode number Is Conflict handling mode

file_type legal value of the list

Value Description The lowest version
1 Json
2 Csv

conflict_mode legal value of the list

Value Description The lowest version
1 INSERT
2 UPSERT

Returns a value

Object

The returned JSON packet

Property Type Description
errcode number Error code
errmsg string The error message
job_id number Import task ID, you can use the database migration progress query API to query the import progress and results

The legal value of errcode

Value Description The lowest version
0 The request was successful
-1 System error
-1000 System error
40014 AccessToken is illegal
40097 The request parameter is wrong
40101 Required parameters are missing
41001 Missing AccessToken
42001 AccessToken expires
43002 HTTP METHOD error
44002 POST BODY is empty
47001 POST BODY format is incorrect
85088 The APP is not open for cloud development
Other error codes Cloud development error code

An example of requesting data

{
	"env": "qbasetest-a5c40e",
	"collection_name": "test1",
	"file_path":"test_import",
	"file_type":1,
	"stop_on_error": false,
	"conflict_mode": 2
}

Return an example of the data

{
    "errcode": 0,
    "errmsg": "ok",
    "job_id": 100074947
}