Skip to content

Commit 5a8ebf5

Browse files
authored
Docs: Add usage samples for each cache option (#112)
1 parent bfad07b commit 5a8ebf5

File tree

5 files changed

+86
-7
lines changed

5 files changed

+86
-7
lines changed

airbyte/caches/bigquery.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2-
"""A BigQuery implementation of the cache."""
2+
"""A BigQuery implementation of the cache.
3+
4+
## Usage Example
5+
6+
```python
7+
import airbyte as ab
8+
from airbyte.caches import BigQueryCache
9+
10+
cache = BigQueryCache(
11+
project_name="myproject",
12+
dataset_name="mydataset",
13+
credentials_path="path/to/credentials.json",
14+
)
15+
```
16+
"""
317

418
from __future__ import annotations
519

@@ -17,8 +31,13 @@ class BigQueryCache(CacheBase):
1731
"""The BigQuery cache implementation."""
1832

1933
project_name: str
34+
"""The name of the project to use. In BigQuery, this is equivalent to the database name."""
35+
2036
dataset_name: str = "airbyte_raw"
37+
"""The name of the dataset to use. In BigQuery, this is equivalent to the schema name."""
38+
2139
credentials_path: str
40+
"""The path to the credentials file to use."""
2241

2342
_sql_processor_class: type[BigQuerySqlProcessor] = BigQuerySqlProcessor
2443

airbyte/caches/duckdb.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2-
"""A DuckDB implementation of the cache."""
2+
"""A DuckDB implementation of the PyAirbyte cache.
3+
4+
## Usage Example
5+
6+
```python
7+
from airbyte as ab
8+
from airbyte.caches import DuckDBCache
9+
10+
cache = DuckDBCache(
11+
db_path="/path/to/my/database.duckdb",
12+
schema_name="myschema",
13+
)
14+
"""
315

416
from __future__ import annotations
517

@@ -27,8 +39,8 @@ class DuckDBCache(CacheBase):
2739
db_path: Union[Path, str]
2840
"""Normally db_path is a Path object.
2941
30-
There are some cases, such as when connecting to MotherDuck, where it could be a string that
31-
is not also a path, such as "md:" to connect the user's default MotherDuck DB.
42+
The database name will be inferred from the file name. For example, given a `db_path` of
43+
`/path/to/my/my_db.duckdb`, the database name is `my_db`.
3244
"""
3345

3446
schema_name: str = "main"

airbyte/caches/motherduck.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
"""A cache implementation for the MotherDuck service, built on DuckDB."""
1+
"""A MotherDuck implementation of the PyAirbyte cache, built on DuckDB.
2+
3+
## Usage Example
4+
5+
```python
6+
from airbyte as ab
7+
from airbyte.caches import MotherDuckCache
8+
9+
cache = MotherDuckCache(
10+
database="mydatabase",
11+
schema_name="myschema",
12+
api_key=ab.get_secret("MOTHERDUCK_API_KEY"),
13+
)
14+
"""
15+
216
from __future__ import annotations
317

418
from overrides import overrides

airbyte/caches/postgres.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2-
"""A Postgres implementation of the cache."""
2+
"""A Postgres implementation of the PyAirbyte cache.
3+
4+
## Usage Example
5+
6+
```python
7+
from airbyte as ab
8+
from airbyte.caches import PostgresCache
9+
10+
cache = PostgresCache(
11+
host="myhost",
12+
port=5432,
13+
username="myusername",
14+
password=ab.get_secret("POSTGRES_PASSWORD"),
15+
database="mydatabase",
16+
)
17+
```
18+
"""
319

420
from __future__ import annotations
521

airbyte/caches/snowflake.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2-
"""A Snowflake implementation of the cache."""
2+
"""A Snowflake implementation of the PyAirbyte cache.
3+
4+
## Usage Example
5+
6+
```python
7+
from airbyte as ab
8+
from airbyte.caches import SnowflakeCache
9+
10+
cache = 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+
"""
321

422
from __future__ import annotations
523

0 commit comments

Comments
 (0)