Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Create a simple magic command connection string

Focus mode
Create a simple magic command connection string - Amazon SageMaker AI

If your administrator has configured the connections to your data sources, follow these steps to easily create a connection string in a notebook cell:

  1. Open a notebook cell that uses %%sm_sql.

  2. Select a pre-configured connection to your desired data source from the connection dropdown menu above the cell.

  3. This will automatically populate the parameters needed to query that data source.

Alternatively, you can specify connection properties inline in the cell.

Choosing a connection from the dropdown menu inserts the following two parameters into the default magic command string. The parameters contain the connection information your administrator configured.

  • --metastore-id: The name of the connection object that holds your connection parameters.

  • --metastore-type: The type of meta-store corresponding to --metastore-id. The SQL extension uses AWS Glue connections as a connection meta-store. This value is automatically set to GLUE_CONNECTION.

For example, the connection string to a pre-configured Amazon Athena data store looks like the following:

%%sm_sql --metastore-id athena-connection-name --metastore-type GLUE_CONNECTION
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.