Create a database (Python)
Creates a database.
To replicate a database to additional datacenters, see Deploy an Astra DB Serverless database to multiple regions.
|
You need an application token with permission to create and configure databases, such as the Organization Administrator role. For more information, see Get endpoint and token. |
Result
Creates a database and returns an AstraDBDatabaseAdmin object that can perform administrative actions on the newly-created database.
Parameters
Use the create_database method, which belongs to the AstraDBAdmin class.
Method signature
create_database(
name: str,
*,
definition: DatabaseDefinition,
wait_until_active: bool,
database_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
token: str | TokenProvider,
spawn_api_options: APIOptions,
) -> AstraDBDatabaseAdmin
create_database(
name: str,
*,
cloud_provider: str,
region: str,
keyspace: str,
wait_until_active: bool,
database_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
token: str | TokenProvider,
spawn_api_options: APIOptions,
) -> AstraDBDatabaseAdmin
| Name | Type | Summary |
|---|---|---|
|
|
The name for the database. Database names must follow these rules:
|
|
The configuration for the database. If specified, you cannot separately specify See Attributes of |
|
|
|
Required unless you specify The cloud provider that should host the database.
Can be one of: |
|
|
Required unless you specify The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions (Python). |
|
|
Optional.
You can’t specify both The name for the database’s initial keyspace. Default: default_keyspace |
|
|
Optional. Whether to wait for the database to become active before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active. Default: true |
|
|
Optional.
A timeout, in milliseconds, to impose on the underlying API request.
If not provided, the This parameter is aliased as |
|
|
Optional.
The token used by the resulting Default: The token used by the |
|
Optional.
A complete or partial specification of the If |
| Name | Type | Summary | ||
|---|---|---|---|---|
|
|
The cloud provider that should host the database.
Can be one of: |
||
|
|
The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions (Python). |
||
|
|
Optional. The name for the database’s initial keyspace. Default: default_keyspace |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
||
|
|
Optional. Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, set it to
Default: vector |
||
|
|
Optional. The database tier. If specified, must be Default: serverless |
||
|
|
Optional. The number of capacity units for the database. This is unrelated to PCU group capacity. If specified, must be Default: 1 |
Examples
The following examples demonstrate how to create a database.
from astrapy import DataAPIClient
from astrapy.info import DatabaseDefinition
client = DataAPIClient("APPLICATION_TOKEN")
admin = client.get_admin()
admin.create_database(
"DATABASE_NAME",
definition=DatabaseDefinition(
cloud_provider="gcp", region="us-east1"
),
)
Client reference
For more information, see the client reference.