EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB485854: Convert data sources based on DSN to be DSN-Less through REST APIs, Data Sources and Scripts entry.


Xiaoqian Lu

Quality Engineer, Principal • MicroStrategy


This article addresses the change starting from MicroStrategy version 2021 Update 8 where privileged users are allowed to convert data sources based on DSN to be DSN-Less through REST APIs and the change starting from MicroStrategy version 2021 Update 9 where privileged users are allowed to convert data sources based on DSN to be DSN-Less through Data Sources and Scripts entry. This article explains how to convert data sources with API in Library server, Data Sources and Scripts entry in Windows and MAC Workstation clients, provides a list of certified gateways and platforms.

Description

Many requests from cloud customers require modifying connection properties to their relational data gateways. To reduce the administration overhead of managing cloud environments for customers, converting data sources based on DSN to be DSN-Less through REST APIs is supported from Strategy 2021 Update 8, converting data sources in Data Sources and Scripts entry in Windows and MAC Workstation clients is supported from Strategy 2021 Update 9.
 

How to use API to convert a data source from DSN to be DSN-Less

With the release of Strategy 2021 Update 8, privileged users can convert a data source from DSN to be DSN-Less is through REST APIs. 
More details about how to use the API, please refer to https://microstrategy.github.io/rest-api-docs/common-workflows/datasource-management/convert-connection-string-from-dsn-to-dsnless-for-a-datasource/
 

Convert a data source created from Web

Step 1. Authenticate a privileged user and get X-MSTR-AuthToken

By POST /api/auth/login, a privileged user is authenticated and an HTTP session is created. This request returns an authorization token (X-MSTR-AuthToken) which will be submitted with subsequent requests.

 

Step 2. Get the data source id

By GET /api/datasource, information for all data sources are returned. You can find the id of the specific data sources. It is expected to see the DSN name in the [database][embeddedConnection][connectionString] field of the response. The authorization token got in Step 1 is needed in the request header. 

 

Step 3. Convert the data source

By POST /api/datasources/{id}/conversion, DSN in data source is converted to DSN-Less connection string and update the object to metadata. Data source id and the authorization token got in Step 1 are needed in the request header. Status code 204 is returned when converting operation is successful.

 

Step 4. Get the information of the converted data source

By GET /api/datasources/{id}, information of converted data source is returned. Data source id and the authorization token got in Step 1 are needed in the request header. It is expected to see the DSNLess connection string in the [database][embeddedConnection][connectionString] field of the response.
 

Convert a data source created from Developer

Step 1. Authenticate a privileged user and get X-MSTR-AuthToken

It’s the same with convert a data source created from Web.

 

Step 2. Get the data source connection id

By GET /api/datasources/connections, information for all datasource connections are returned. You can find the id of the specific data source connection. It is expected to see the DSN name in the [connectionString] field of the response. The authorization token got in Step 1 is needed in the request header. 

 

Step 3. Convert the data source connection

By POST /datasources/connections/{id}/conversion, DSN in data source connection is converted to DSN-Less connection string and update the object to metadata. Data source connection id and the authorization token got in Step 1 are needed in the request header. Status code 204 is returned when converting operation is successful.

 

Step 4.  Get the information of the converted data source connection

By GET /api/datasources/connections/{id}, information of converted data source connection is returned. Data source connection id and the authorization token got in Step 1 are needed in the request header. It is expected to see the DSNLess connection string in the [connectionString] field of the response.
 

How to convert a data source from DSN to be DSN-Less in Data Sources entry since Strategy 2021 Update 9

Step 1. Connect to Library Server in Workstation

Connect to Library Server by a privileged user in Windows or MAC Workstation.

Step 2. Convert a data source in Data Sources entry

Click to enter Data Sources entry, RMC a data source in Data Sources tab. Edit the data source.

ka0PW0000003UhVYAU_0EM4W000006zneG.jpeg

Click the Convert to DSN-less button to convert the data source.

ka0PW0000003UhVYAU_0EM4W000006zneP.jpeg

 

Step 3. Save the converted data source.

Once the Convert to DSN-less button is clicked, the data source is converted, no matter user clicks Save button or not. Of course, user can modify the converted data source and save afterwards.
 

How to convert a data source from DSN to be DSN-Less in Scripts entry since Strategy 2021 Update 9

Convert a data source created from Web

Step 1. Connect to Library Server in Workstation

It’s same with convert a data source from DSN to be DSN-Less in Data Sources entry.
 

Step 2. Convert a data source created from Web in Scrips entry

Click to enter Scripts entry. Create a new script and Run. Sample codes are listed below.

from mstrio.connection import Connectionfrom mstrio.datasources import (DatasourceInstance, list_datasource_instances)from pprint import pprintlibrary_url = 'your library server url'user_name = 'username to connect to library server'user_password = 'password to connect to library server'project_name = 'project name'conn = Connection(base_url=library_url, username=user_name, password=user_password, project_name=project_name)ds = DatasourceInstance(conn, id='data source id')pprint(ds.list_properties())ds.convert_ds_connection_to_dsn_less()pprint(ds.list_properties())

Use a for loop if there are multiple data sources to convert.
for ds_id in DATASOURCE_INSTANCE_ID_DSN_LIST:    ds_instance = DatasourceInstance(conn, id='data source id')    ds_instance.convert_ds_connection_to_dsn_less()

More detailed explanation of the functions can be found in Gallery → Code Snippets → datasource mgmt.
 

Convert a data source created from Developer

Step 1. Connect to Library Server in Workstation

It’s same with convert a data source from DSN to be DSN-Less in Data Sources entry.

Step 2. Convert a data source created from Developer in Scrips entry

Click to enter Scripts entry. Create a new script and Run. Sample codes are listed below.

from mstrio.connection import Connectionfrom mstrio.datasources import (list_datasource_instances, DatasourceConnection)from pprint import pprintfrom mstrio.datasources.datasource_connection import list_datasource_connectionslibrary_url = 'your library server url'user_name = 'username to connect to library server'user_password = 'password to connect to library server'project_name = 'project name'conn = Connection(base_url=library_url, username=user_name, password=user_password, project_name=project_name)ds_conn = DatasourceConnection(conn, id='database connection id')pprint(ds_conn.list_properties())ds_conn.convert_to_dsn_less()pprint(ds_conn.list_properties())

Use a for loop if there are multiple database connections to convert.
for ds_conn_id in DATASOURCE_CONNECTION_ID_DSN_LIST:    ds_conn = DatasourceConnection(conn, id='database connection id'))    ds_conn.convert_to_dsn_less()

More detailed explanation of the functions can be found in Gallery → Code Snippets → datasource mgmt.
 

Certified Gateways

  • Amazon Redshift
  • Azure Synapse Analytics
  • Exasol
  • IBM Db2 for Linux, UNIX and Windows
  • MySQL
  • Oracle
  • PostgreSQL
  • Salesforce
  • MongoDB (connectivity failure after conversion, more details and workarounds in Case#7 and Case#8 in Known Limitations section)
  • Cloudera Hive
  • Cloudera Impala
  • Google BigQuery
  • Spark SQL
  • SAP HANA
  • Snowflake
  • SQL Server
  • Teradata (Only data source in Linux platform is supported in Data Sources entry)

 

Certified Platforms

  • Windows
  • Linux

 

Known limitations

Case #1

Connection strings are different between Windows and Linux platform after conversion. Keys with empty value are returned in DSN-Less connection string in Linux platform but not in Windows platform.
Example of connection string in Window platform:

DRIVER={Strategy ODBC Driver for PostgreSQL Wire Protocol};APPLICATIONUSINGTHREADS=1;DATABASE=<database>;DEFAULTLONGDATABUFFLEN=1024;DESCRIPTION=Strategy ODBC Driver for PostgreSQL Wire Protocol;ENABLEDESCRIBEPARAM=1;ENCRYPTIONMETHOD=0;FETCHTSWTZASTIMESTAMP=1;FETCHTWFSASTIME=1;HOSTNAME=<hostname>;PORTNUMBER=<portnumber>;TRANSACTIONERRORBEHAVIOR=0;UID=<username>;VALIDATESERVERCERTIFICATE=1;XMLDESCRIBETYPE=-10;

Example of connection string in Linux platform:
DRIVER={Strategy ODBC Driver for PostgreSQL Wire Protocol};ALTERNATESERVERS=;APPLICATIONUSINGTHREADS=1;AUTHENTICATIONMETHOD=0;BATCHMECHANISM=1;CLIENTSSLCERTIFICATE=;CLIENTSSLKEY=;CONNECTIONRESET=0;CONNECTIONRETRYCOUNT=0;CONNECTIONRETRYDELAY=3;CRYPTOPROTOCOLVERSION=;DATABASE=<database>;DESCRIPTION=Strategy ODBC Driver for PostgreSQL Wire Protocol;ENABLEDESCRIBEPARAM=1;ENABLEKEYSETCURSORS=0;ENCRYPTIONMETHOD=0;EXTENDEDCOLUMNMETADATA=0;EXTENDEDOPTIONS=;FAILOVERGRANULARITY=0;FAILOVERMODE=0;FAILOVERPRECONNECT=0;FETCHREFCURSOR=1;FETCHTSWTZASTIMESTAMP=0;FETCHTWFSASTIME=0;GSSCLIENT=native;HOSTNAME=<hostname>;HOSTNAMEINCERTIFICATE=;INITIALIZATIONSTRING=;KEEPALIVE=0;KEYPASSWORD=;KEYSTORE=;KEYSTOREPASSWORD=;KEYSETCURSOROPTIONS=0;LOADBALANCETIMEOUT=0;LOADBALANCING=0;LOGINTIMEOUT=15;MAXCHARSIZE=;MAXLONGVARCHARSIZE=;MAXPOOLSIZE=100;MAXVARCHARSIZE=;MINPOOLSIZE=0;POOLING=0;PORTNUMBER=<portnumber>;QUERYTIMEOUT=0;REPORTCODEPAGECONVERSIONERRORS=0;SERVICEPRINCIPALNAME=;TRANSACTIONERRORBEHAVIOR=1;TRUSTSTORE=;TRUSTSTOREPASSWORD=;UNBOUNDEDNUMERICPRECISION=1000;UNBOUNDEDNUMERICSCALE=6;VALIDATESERVERCERTIFICATE=1;XMLDESCRIBETYPE=-10;

 

Case #2

Some parameters in the converted DSN-Less connection string are lost when editing data sources in Web in Strategy 2021 Update 8. The lost parameters are the ones not in the DSN-Less template in Web. 
Solution: The issue is fixed in Strategy 2021 Update 9.
 

Case #3

Value of DESCRIPTION is malformed in Advanced tab of Data Sources entry in Workstation in Strategy 2021 Update 8 with error:
The provided parameters contain errors. The correct format is “key=value“. 

ka0PW0000003UhVYAU_0EM4W000006HkYM.jpeg

Solution: The issue is fixed in Strategy 2021 Update 9.

Case #4

Fail to save data sources after editing in Data Source entry in Workstation with error in Advanced tab:
Key “ValidateServerCertificate“ is already defined in a separate form field.

ka0PW0000003UhVYAU_0EM4W000006HkYR.jpeg

Solution: Remove the redundant ValidateServerCertificate key-value pair.

Case #5

Password is not removed in the converted DSN-Less connection string when using PostgreSQL native ODBC driver.
 

Case #6

PostgreSQL data sources fail to connect after converting DSN to DSN-Less with error:
Database error<5>: Connect failed. Error type: Odbc error. Odbc operation attempted: SQLDriverConnect. [HY000:0: on SQLHANDLE][Strategy][ODBC PostgreSQL Wire Protocol driver] Invalid attribute in connection string: XO.
Solution: Edit the connection string and remove parameters EXTENDEDOPTIONS=; in the connection string.
 

Case #7

MongoDB data sources fail to connect after converting DSN to DSN-Less with error in Linux platform:
(Database error <5>: Connect failed. Error type: Odbc error. Odbc operation attempted: SQLDriverConnect. [HY000:2704: on SQLHANDLE] [Strategy][ODBC MongoDB driver]Error parsing connect string at offset 697. Attribute specified twice using keywords 'UID' and 'LOGONID'.)
Solution: Edit the connection string and remove parameters LOGONID=; in the connection string.
 

Case #8

MongoDB data sources fail to connect after converting DSN to DSN-Less with error in Windows platform:
(Database error <5>: Connect failed. Error type: Odbc error. Odbc operation attempted: SQLDriverConnect. [HY000:2704: on SQLHANDLE] [Strategy][ODBC MongoDB driver]Error parsing connect string at offset 193. )
or
(Database error <5>: Connect failed. Error type: Odbc error. Odbc operation attempted: SQLDriverConnect. [HY000:2704: on SQLHANDLE] [Strategy][ODBC MongoDB driver]Error parsing connect string at offset 476. Attribute specified twice using keywords 'FS' and 'FetchSize'.)
Solution: Edit the connection string and remove parameters FETCHSIZE=100; <your_mongo_db_odbc_driver_path>/sforce.jar; in the connection string.
 

Case #9

Key value in Additional connection string parameters of Exasol DSN can not be converted successfully.

ka0PW0000003UhVYAU_0EM4W000006HkZ5.jpeg

The value in registry is as below

ka0PW0000003UhVYAU_0EM4W000006HkZA.jpeg

After converted using API, the connection string is:

DRIVER={EXASolution Driver};ADDITIONAL PARAMS="SSLCertificate=<your_certificate_path>";EXA PWD=;EXA SERVER=;EXA UID=;ENCRYPTION=Y;PREPARE AS=N;QUERY TIMEOUT=0;SHOWONLYCURRENTSCHEMA=N;

This connection string will not work.
Solution: Use connection string below:
DRIVER={EXASolution Driver};SSLCertificate=<your_certificate_path>;EXA PWD=;EXA SERVER=;EXA UID=;ENCRYPTION=Y;PREPARE AS=N;QUERY TIMEOUT=0;SHOWONLYCURRENTSCHEMA=N;

 

Case #10

Standalone data sources created in Developer are not able to go through OAuth workflow for Azure Synapse Analytics.

  • If we add OAuth parameters in Developer 'Additional parameter', the Connection is not able to edit in Data Source​​.
  • Define  'Additional parameter' in Data Source, it turns out to Pre-configured as Authentication Method and we could not attach IAM objects.

 

Case #11

The database connections can’t be edited in Data Sources entry after converting when data sources are from Spark SQL, Cloudera Hive, Cloudera Impala, Google BigQuery(in Windows platform), SAP HANA, Oracle TNS.
 

Case #12

Key “AUTHENTICATION“ is already defined in a separate form field warning after converting a Teradata data source.

ka0PW0000003UhVYAU_0EM4W000006znej.jpeg

Solution: Remove the redundant AUTHENTICATION key-value pair in Advanced tab.
 

Case #13

Convert to DSN-less button is disabled when the data source is from PostgreSQL Native driver.
Solution: User API or Python Scripts to convert the data source.
 

Case #14

Trust store is lost when editing a converted data source which is created with trust store from Web. When trying to connect the converted data source, error is like:

(Database error<5>: Connect failed. Error type: ODBC error. Odbc operation attempted: SQLDriverConnect. [28000:0: on SQL HANDLE] [Strategy][ODBC Database Wire Protocol driver]Cannot load trust store. %1)

Solution: Do not edit the data source after conversion.
 


Comment

0 comments

Details

Knowledge Article

Published:

December 13, 2022

Last Updated:

October 24, 2024