Skip to content

Commit

Permalink
very basic motherduck cache
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Feb 16, 2024
1 parent e2e8f0b commit b7a127e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions airbyte/caches/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from airbyte.caches.base import SQLCacheBase
from airbyte.caches.duckdb import DuckDBCache, DuckDBCacheConfig
from airbyte.caches.motherduck import MotherDuckCache, MotherDuckCacheConfig
from airbyte.caches.postgres import PostgresCache, PostgresCacheConfig
from airbyte.caches.snowflake import SnowflakeCacheConfig, SnowflakeSQLCache

Expand All @@ -11,6 +12,8 @@
__all__ = [
"DuckDBCache",
"DuckDBCacheConfig",
"MotherDuckCache",
"MotherDuckCacheConfig",
"PostgresCache",
"PostgresCacheConfig",
"SQLCacheBase",
Expand Down
31 changes: 31 additions & 0 deletions airbyte/caches/motherduck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""A cache implementation for the MotherDuck service, built on DuckDB."""
from __future__ import annotations

from overrides import overrides

from airbyte.caches.duckdb import DuckDBCacheBase, DuckDBCacheConfig


class MotherDuckCacheConfig(DuckDBCacheConfig):
"""Configuration for the MotherDuck cache."""

db_path = "md:"
database: str
api_key: str

@overrides
def get_sql_alchemy_url(self) -> str:
"""Return the SQLAlchemy URL to use."""
# return f"duckdb:///{self.db_path}?schema={self.schema_name}"
return f"duckdb:///md:{self.api_key}@{self.database}"

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


class MotherDuckCache(DuckDBCacheBase):
"""A cache implementation for the MotherDuck service, built on DuckDB."""

config_class = MotherDuckCacheConfig

0 comments on commit b7a127e

Please sign in to comment.