Updated on 2025-09-04 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 target instance and ECS must be in the same VPC and subnet.
  • The instance security group must allow access from the ECS.

    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.
  • For details about how to create an ECS, see Purchasing an ECS in Getting Started with Elastic Cloud Server.
  • JDK has been installed on the ECS.

Obtaining the IP Address of a GeminiDB DynamoDB-Compatible Instance

  1. Log in to the Huawei Cloud console.
  2. In the service list, choose Databases > GeminiDB.
  3. On the Instances page, click the instance name. On the displayed Basic Information page, view IP addresses of the load balancer and each node.

    If no load balancer address is available, choose Service Tickets > Create Service Ticket in the upper right corner of the console and contact the customer service.

    Figure 1 Viewing the IP address

Replace the IP address in the following code example with the IP address queried in 3.

Python code example:

#!/usr/bin/python  
import boto3  
 

url = 'http://***.***.***.***'  
dynamodb = boto3.resource('dynamodb',  
                          endpoint_url=url,  
                          aws_access_key_id='ak',  
                          aws_secret_access_key='sk',  
                          region_name="region-a")  

GeminiDB DynamoDB-Compatible API is completely compatible with DynamoDB. For details about common operations, see official DynamoDB documents.