airbyte.caches.snowflake

A Snowflake implementation of the PyAirbyte cache.

Usage Example

from airbyte as ab
from airbyte.caches import SnowflakeCache

cache = SnowflakeCache(
    account="myaccount",
    username="myusername",
    password=ab.get_secret("SNOWFLAKE_PASSWORD"),
    warehouse="mywarehouse",
    database="mydatabase",
    role="myrole",
    schema_name="myschema",
)
 1# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
 2"""A Snowflake implementation of the PyAirbyte cache.
 3
 4## Usage Example
 5
 6```python
 7from airbyte as ab
 8from airbyte.caches import SnowflakeCache
 9
10cache = SnowflakeCache(
11    account="myaccount",
12    username="myusername",
13    password=ab.get_secret("SNOWFLAKE_PASSWORD"),
14    warehouse="mywarehouse",
15    database="mydatabase",
16    role="myrole",
17    schema_name="myschema",
18)
19```
20"""
21
22from __future__ import annotations
23
24from overrides import overrides
25from snowflake.sqlalchemy import URL
26
27from airbyte._processors.sql.base import RecordDedupeMode
28from airbyte._processors.sql.snowflake import SnowflakeSqlProcessor
29from airbyte.caches.base import CacheBase
30from airbyte.secrets import SecretString
31
32
33class SnowflakeCache(CacheBase):
34    """Configuration for the Snowflake cache."""
35
36    account: str
37    username: str
38    password: SecretString
39    warehouse: str
40    database: str
41    role: str
42
43    dedupe_mode = RecordDedupeMode.APPEND
44
45    _sql_processor_class = SnowflakeSqlProcessor
46
47    # Already defined in base class:
48    # schema_name: str
49
50    @overrides
51    def get_sql_alchemy_url(self) -> SecretString:
52        """Return the SQLAlchemy URL to use."""
53        return SecretString(
54            URL(
55                account=self.account,
56                user=self.username,
57                password=self.password,
58                database=self.database,
59                warehouse=self.warehouse,
60                schema=self.schema_name,
61                role=self.role,
62            )
63        )
64
65    @overrides
66    def get_database_name(self) -> str:
67        """Return the name of the database."""
68        return self.database
class SnowflakeCache(airbyte.caches.base.CacheBase):
34class SnowflakeCache(CacheBase):
35    """Configuration for the Snowflake cache."""
36
37    account: str
38    username: str
39    password: SecretString
40    warehouse: str
41    database: str
42    role: str
43
44    dedupe_mode = RecordDedupeMode.APPEND
45
46    _sql_processor_class = SnowflakeSqlProcessor
47
48    # Already defined in base class:
49    # schema_name: str
50
51    @overrides
52    def get_sql_alchemy_url(self) -> SecretString:
53        """Return the SQLAlchemy URL to use."""
54        return SecretString(
55            URL(
56                account=self.account,
57                user=self.username,
58                password=self.password,
59                database=self.database,
60                warehouse=self.warehouse,
61                schema=self.schema_name,
62                role=self.role,
63            )
64        )
65
66    @overrides
67    def get_database_name(self) -> str:
68        """Return the name of the database."""
69        return self.database

Configuration for the Snowflake cache.

account: str
username: str
warehouse: str
database: str
role: str
dedupe_mode
@overrides
def get_sql_alchemy_url(self) -> airbyte.secrets.base.SecretString:
51    @overrides
52    def get_sql_alchemy_url(self) -> SecretString:
53        """Return the SQLAlchemy URL to use."""
54        return SecretString(
55            URL(
56                account=self.account,
57                user=self.username,
58                password=self.password,
59                database=self.database,
60                warehouse=self.warehouse,
61                schema=self.schema_name,
62                role=self.role,
63            )
64        )

Return the SQLAlchemy URL to use.

@overrides
def get_database_name(self) -> str:
66    @overrides
67    def get_database_name(self) -> str:
68        """Return the name of the database."""
69        return self.database

Return the name of the database.

Inherited Members
pydantic.main.BaseModel
BaseModel
Config
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
airbyte.caches.base.CacheBase
cache_dir
cleanup
schema_name
table_prefix
table_suffix
processor
get_sql_engine
streams