Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
ksaranraj5
Partner - Contributor II
Partner - Contributor II

Update existing load script for a table through qlik engine API

Hi,

I'm trying to update the Load script of specific table through Qlik engine API,

I have explore the following things,

To get the tables and key I have done the following engine api request

{
	"handle": 1,
	"method": "GetTablesAndKeys",
	"params": {
		"qWindowSize": {
			"qcx": 0,
			"qcy": 0
		},
		"qNullSize": {
			"qcx": 0,
			"qcy": 0
		},
		"qCellHeight": 0,
		"qSyntheticMode": false,
		"qIncludeSysVars": false,
		"qIncludeProfiling": false
	}
}

 It results the following sample response

{
	"jsonrpc": "2.0",
	"id": 3,
	"delta": true,
	"result": {
		"qtr": [
			{
				"qName": "PRODUCT_CATEGORIES",
				"qNoOfRows": 5,
				"qFields": [
					{
						"qName": "CATEGORY_ID",
						"qOriginalFields": [],
						"qPresent": true,
						"qInformationDensity": 1,
						"qnNonNulls": 5,
						"qnRows": 5,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 5,
						"qnPresentDistinctValues": 5,
						"qKeyType": "ANY_KEY",
						"qTags": [
							"$key",
							"$numeric",
							"$integer"
						],
						"qDerivedFields": []
					},
					{
						"qName": "CATEGORY_NAME",
						"qOriginalFields": [],
						"qPresent": true,
						"qInformationDensity": 1,
						"qnNonNulls": 5,
						"qnRows": 5,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 5,
						"qnPresentDistinctValues": 5,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$ascii",
							"$text"
						],
						"qDerivedFields": []
					},
					{
						"qName": "len_category",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 5,
						"qnRows": 5,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 4,
						"qnPresentDistinctValues": 4,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$numeric",
							"$integer"
						],
						"qDerivedFields": []
					},
					{
						"qName": "upper_category",
						"qOriginalFields": [],
						"qPresent": true,
						"qInformationDensity": 1,
						"qnNonNulls": 5,
						"qnRows": 5,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 5,
						"qnPresentDistinctValues": 5,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$ascii",
							"$text"
						],
						"qDerivedFields": []
					}
				],
				"qPos": {
					"qx": 0,
					"qy": 0
				},
				"qTableTags": [],
				"qProfilingData": {
					"qNoOfRows": 0,
					"qFieldProfiling": []
				}
			},
			{
				"qName": "PRODUCTS",
				"qNoOfRows": 288,
				"qFields": [
					{
						"qName": "CATEGORY_ID",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 0.8,
						"qnTotalDistinctValues": 5,
						"qnPresentDistinctValues": 4,
						"qKeyType": "ANY_KEY",
						"qTags": [
							"$key",
							"$numeric",
							"$integer"
						],
						"qDerivedFields": []
					},
					{
						"qName": "PRODUCT_ID",
						"qOriginalFields": [],
						"qPresent": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 288,
						"qnPresentDistinctValues": 288,
						"qKeyType": "ANY_KEY",
						"qTags": [
							"$key",
							"$numeric",
							"$integer"
						],
						"qDerivedFields": []
					},
					{
						"qName": "PRODUCT_NAME",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 242,
						"qnPresentDistinctValues": 242,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$ascii",
							"$text"
						],
						"qDerivedFields": []
					},
					{
						"qName": "DESCRIPTION",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 206,
						"qnPresentDistinctValues": 206,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$ascii",
							"$text"
						],
						"qDerivedFields": []
					},
					{
						"qName": "STANDARD_COST",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 287,
						"qnPresentDistinctValues": 287,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$numeric"
						],
						"qDerivedFields": []
					},
					{
						"qName": "LIST_PRICE",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 249,
						"qnPresentDistinctValues": 249,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$numeric"
						],
						"qDerivedFields": []
					},
					{
						"qName": "replace_product",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 242,
						"qnPresentDistinctValues": 242,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$ascii",
							"$text"
						],
						"qDerivedFields": []
					},
					{
						"qName": "Cat_Name",
						"qOriginalFields": [],
						"qPresent": true,
						"qHasDuplicates": true,
						"qInformationDensity": 1,
						"qnNonNulls": 288,
						"qnRows": 288,
						"qSubsetRatio": 1,
						"qnTotalDistinctValues": 4,
						"qnPresentDistinctValues": 4,
						"qKeyType": "NOT_KEY",
						"qTags": [
							"$ascii",
							"$text"
						],
						"qDerivedFields": []
					}
				],
				"qPos": {
					"qx": 0,
					"qy": 0
				},
				"qTableTags": [],
				"qProfilingData": {
					"qNoOfRows": 0,
					"qFieldProfiling": []
				}
			},
		],
		"qk": [
			{
				"qKeyFields": [
					"CATEGORY_ID"
				],
				"qTables": [
					"PRODUCT_CATEGORIES",
					"PRODUCTS"
				]
			},
		]
	}
}

Here I can get tables, fields and keys.

I'm looking for an API that does the create tables and set keys between table and adding calculated column to an existing table.

Labels (4)
5 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can set the entire script, followed by a reload, to add data. I don't know of an API that would let you modify or add only a part of the script. 

-Rob

ksaranraj5
Partner - Contributor II
Partner - Contributor II
Author

Thanks for the clarification it saves me a lot of time.

Now I am looking for 2 API's:

1.adding a data source ex:adding oracle datasource to an application.

2.Selecting a table from the added data source and inserting it.

loadscript.PNG

script.PNG

I am looking for an API that does the same as above two images.

If this is possible through API I can get that entire loadscript and update it from our code  and I can replace this loadscript with the existing one, Is that possible through API?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

With the engine API, you can add and modify Data Connections.  You can also replace the entire loadscript with an app.SetScript call.

-Rob

ksaranraj5
Partner - Contributor II
Partner - Contributor II
Author

Thanks for that reply.

As I have shown in a screenshot above can I also insert a table using API ?

as I need to get a Insert Script for the added table.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can get some of that table metadata I think using the app.GetFile* methods.  

https://help.qlik.com/en-US/sense-developer/November2021/Subsystems/EngineJSONAPI/Content/service-do...