Query SAS xpt Data as a MySQL Database in Node.js

Ready to get started?

Learn more or sign up for a free trial:

CData Connect



Execute MySQL queries against SAS xpt data from Node.js.

You can use CData Connect Cloud to query SAS xpt data through a MySQL interface. Follow the procedure below to create a virtual database for SAS xpt in Connect Cloud and start querying using Node.js.

CData Connect Cloud provides a pure MySQL, cloud-to-cloud interface for SAS xpt, allowing you to easily query live SAS xpt data in Node.js — without replicating the data to a natively supported database. As you query data in Node.js, CData Connect Cloud pushes all supported SQL operations (filters, JOINs, etc) directly to SAS xpt, leveraging server-side processing to quickly return SAS xpt data.

Create a Virtual MySQL Database for SAS xpt Data

CData Connect Cloud uses a straightforward, point-and-click interface to connect to data sources and generate APIs.

  1. Login to Connect Cloud and click Databases.
  2. Select "SAS xpt" from Available Data Sources.
  3. Enter the necessary authentication properties to connect to SAS xpt.

    Connecting to Local SASXpt Files

    You can connect to local SASXpt file by setting the URI to a folder containing SASXpt files.

    Connecting to S3 data source

    You can connect to Amazon S3 source to read SASXpt files. Set the following properties to connect:

    • URI: Set this to the folder within your bucket that you would like to connect to.
    • AWSAccessKey: Set this to your AWS account access key.
    • AWSSecretKey: Set this to your AWS account secret key.
    • TemporaryLocalFolder: Set this to the path, or URI, to the folder that is used to temporarily download SASXpt file(s).

    Connecting to Azure Data Lake Storage Gen2

    You can connect to ADLS Gen2 to read SASXpt files. Set the following properties to connect:

    • URI: Set this to the name of the file system and the name of the folder which contacts your SASXpt files.
    • AzureAccount: Set this to the name of the Azure Data Lake storage account.
    • AzureAccessKey: Set this to our Azure DataLakeStore Gen 2 storage account access key.
    • TemporaryLocalFolder: Set this to the path, or URI, to the folder that is used to temporarily download SASXpt file(s).

  4. Click Test Database.
  5. Click Privileges -> Add and add the new user (or an existing user) with the appropriate permissions.

With the virtual database created, you are ready to connect to SAS xpt data from any MySQL client.

Query SAS xpt from Node.js

The following example shows how to define a connection and execute queries to SAS xpt with the MySQL module. You will need the following information:

  • Host name, or address, and port: The address of your instance of the Connect Cloud (myinstance.cdatacloud.net) and the port (3306)
  • Username and password: The username and password of a user you authorized on Connect Cloud
  • Database name: The database you configured for SAS xpt (sasxptdb)

Connect to SAS xpt data and start executing queries with the code below:

var mysql      = require('mysql');
var fs         = require('fs');
var connection = mysql.createConnection({
  host     : 'myinstance.cdatacloud.net',
  database : 'sasxptdb',
  port	   : '3306',
  user     : 'admin',
  password : 'password',
  ssl      : {
    ca : fs.readFileSync('C:/certs/myCA.pem')
  }
});
connection.connect();
connection.query('SELECT * FROM SampleTable_1', function(err, rows, fields) {
  if (err) throw err;
  console.log(rows);
});

connection.end();