All Products
Search
Document Center

AnalyticDB:Create a namespace

Last Updated:Jun 11, 2024

This topic describes how to create a namespace, which is used for creating a document collection subsequently.

Sample code

def create_namespace(account, account_password, namespace, namespace_password):
    request = gpdb_20160503_models.CreateNamespaceRequest(
        region_id=ADBPG_INSTANCE_REGION,
        dbinstance_id=ADBPG_INSTANCE_ID,
        manager_account=account,
        manager_account_password=account_password,
        namespace=namespace,
        namespace_password=namespace_password
    )
    response = get_client().create_namespace(request)
    print(f"create_namespace response code: {response.status_code}, body:{response.body}")


if __name__ == '__main__':
    create_namespace("testacc", "Test1234", "ns1", "Ns1password")


# output: body:
# {
#    "Message":"success",
#    "RequestId":"78356FC9-1920-1E09-BB7B-CCB6BD267124",
#    "Status":"success"
# }

Descriptions of parameters in the create_namespace function:

  • account: the initial account of the AnalyticDB for PostgreSQL instance.

  • account_password: the password of the initial account.

  • namespace: the name of the namespace to be created.

  • namespace_password: the password of the namespace. This password is used for subsequent data reads and writes.

View database changes

After you run the preceding code, you can log on to the Data Management (DMS) console to check that the relevant schema is added to the knowledgebase database of the instance.