Titan Core
  • Overview
  • Getting Started
  • Working With Resources
  • Blueprint
  • GitHub Action
  • Resources
    • APIAuthenticationSecurityIntegration
    • APIIntegration
    • AccountParameter
    • AggregationPolicy
    • Alert
    • AuthenticationPolicy
    • AzureStorageIntegration
    • ComputePool
    • Database
    • DatabaseRole
    • DynamicTable
    • EmailNotificationIntegration
    • EventTable
    • ExternalAccessIntegration
    • ExternalStage
    • FailoverGroup
    • FutureGrant
    • GCSStorageIntegration
    • GenericSecret
    • GlueCatalogIntegration
    • Grant
    • GrantOnAll
    • HybridTable
    • ImageRepository
    • InternalStage
    • JSONFileFormat
    • JavascriptUDF
    • MaterializedView
    • NetworkPolicy
    • NetworkRule
    • OAuthSecret
    • ObjectStoreCatalogIntegration
    • PackagesPolicy
    • ParquetFileFormat
    • PasswordPolicy
    • PasswordSecret
    • Pipe
    • PythonStoredProcedure
    • PythonUDF
    • ReplicationGroup
    • ResourceMonitor
    • Role
    • RoleGrant
    • S3StorageIntegration
    • Schema
    • Sequence
    • Service
    • SessionPolicy
    • Share
    • SnowflakePartnerOAuthSecurityIntegration
    • SnowservicesOAuthSecurityIntegration
    • StageStream
    • Table
    • TableStream
    • Tag
    • Task
    • User
    • View
    • ViewStream
    • Warehouse
Powered by GitBook
On this page
  • Examples
  • Python
  • YAML
  • Fields
  1. Resources

Database

PreviousComputePoolNextDatabaseRole

Last updated 10 months ago

Represents a database in Snowflake.

Examples

Python

database = Database(
    name="some_database",
    transient=True,
    owner="SYSADMIN",
    data_retention_time_in_days=7,
    max_data_extension_time_in_days=28,
    default_ddl_collation="utf8",
    tags={"project": "research", "priority": "high"},
    comment="This is a database."
)

A database can contain schemas. In Python, you can add a schema to a database in several ways: By database name:

sch = Schema(
    name = "some_schema",
    database = "my_test_db",
)

By database object:

db = Database(name = "my_test_db")
sch = Schema(
    name = "some_schema",
    database = db,
)

Or using the add method:

db = Database(name = "my_test_db")
sch = Schema(name = "some_schema")
db.add(sch)

YAML

databases:
  - name: some_database
    transient: true
    owner: SYSADMIN
    data_retention_time_in_days: 7
    max_data_extension_time_in_days: 28
    default_ddl_collation: utf8
    tags:
      project: research
      priority: high
    comment: This is a database.

In yaml, you can add schemas to a database using the schemas field:

databases:
  - name: some_database
    schemas:
      - name: another_schema

Or by name:

databases:
  - name: some_database
schemas:
    - name: another_schema
      database: some_database

Fields

  • name (string, required) - The name of the database.

  • transient (bool) - Specifies if the database is transient. Defaults to False.

  • data_retention_time_in_days (int) - The number of days to retain data. Defaults to 1.

  • max_data_extension_time_in_days (int) - The maximum number of days to extend data retention. Defaults to 14.

  • default_ddl_collation (string) - The default collation for DDL statements.

  • tags (dict) - A dictionary of tags associated with the database.

  • comment (string) - A comment describing the database.

owner (string or ) - The owner role of the database. Defaults to "SYSADMIN".

Snowflake Documentation
Role