Updated on 2026-07-10 GMT+08:00

Connecting to a GeminiDB DynamoDB-Compatible Instance Using Python

This section describes how to connect to a GeminiDB DynamoDB-Compatible instance using Python.

Usage Notes

  • The instance and ECS must be in the same region, VPC, and subnet.
  • The ECS must be allowed by the security group associated with the instance.

    Scenario 1: If the instance is associated with the default security group, you do not need to set security group rules.

    Scenario 2: If the instance is not associated with the default security group, check whether the security group rules allow access from the ECS.

Prerequisites

  • A GeminiDB DynamoDB-Compatible instance has been created.
  • An ECS has been created. For details about how to create an ECS, see Purchasing an ECS in the Elastic Cloud Server documentation.
  • Python and Boto3 have been installed on the ECS.

    To manually install Boto3, run pip install boto3.

Obtaining the Connection Address of a GeminiDB DynamoDB-Compatible Instance

  1. Log in to the Huawei Cloud console.
  2. On the Instances page, click the target instance name. On the displayed Basic Information page, view the load balancer address.

    If no load balancer address is available, submit a service ticket on the console to contact the customer service.

    Figure 1 Viewing the IP address

Python Connection Code

GeminiDB is fully compatible with DynamoDB APIs. This section provides only some example code snippets.

Replace the IP address in the following code example with the load balancer address queried in 2.

Python code example:

#!/usr/bin/python  
import boto3  
 

url = 'http://ip'  
dynamodb = boto3.resource('dynamodb',  
                          endpoint_url=url,  
                          aws_access_key_id='rwuser',  
                          aws_secret_access_key='your_pwd',  
                          region_name="region-a")