airbyte.caches.postgres
A Postgres implementation of the PyAirbyte cache.
Usage Example
from airbyte as ab
from airbyte.caches import PostgresCache
cache = PostgresCache(
host="myhost",
port=5432,
username="myusername",
password=ab.get_secret("POSTGRES_PASSWORD"),
database="mydatabase",
)
1# Copyright (c) 2023 Airbyte, Inc., all rights reserved. 2"""A Postgres implementation of the PyAirbyte cache. 3 4## Usage Example 5 6```python 7from airbyte as ab 8from airbyte.caches import PostgresCache 9 10cache = PostgresCache( 11 host="myhost", 12 port=5432, 13 username="myusername", 14 password=ab.get_secret("POSTGRES_PASSWORD"), 15 database="mydatabase", 16) 17``` 18""" 19 20from __future__ import annotations 21 22from overrides import overrides 23 24from airbyte._processors.sql.postgres import PostgresSqlProcessor 25from airbyte.caches.base import CacheBase 26from airbyte.secrets import SecretString 27 28 29class PostgresCache(CacheBase): 30 """Configuration for the Postgres cache. 31 32 Also inherits config from the JsonlWriter, which is responsible for writing files to disk. 33 """ 34 35 host: str 36 port: int 37 username: str 38 password: SecretString 39 database: str 40 41 _sql_processor_class = PostgresSqlProcessor 42 43 @overrides 44 def get_sql_alchemy_url(self) -> SecretString: 45 """Return the SQLAlchemy URL to use.""" 46 return SecretString( 47 f"postgresql+psycopg2://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}" 48 ) 49 50 @overrides 51 def get_database_name(self) -> str: 52 """Return the name of the database.""" 53 return self.database
30class PostgresCache(CacheBase): 31 """Configuration for the Postgres cache. 32 33 Also inherits config from the JsonlWriter, which is responsible for writing files to disk. 34 """ 35 36 host: str 37 port: int 38 username: str 39 password: SecretString 40 database: str 41 42 _sql_processor_class = PostgresSqlProcessor 43 44 @overrides 45 def get_sql_alchemy_url(self) -> SecretString: 46 """Return the SQLAlchemy URL to use.""" 47 return SecretString( 48 f"postgresql+psycopg2://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}" 49 ) 50 51 @overrides 52 def get_database_name(self) -> str: 53 """Return the name of the database.""" 54 return self.database
Configuration for the Postgres cache.
Also inherits config from the JsonlWriter, which is responsible for writing files to disk.
password: airbyte.secrets.base.SecretString
44 @overrides 45 def get_sql_alchemy_url(self) -> SecretString: 46 """Return the SQLAlchemy URL to use.""" 47 return SecretString( 48 f"postgresql+psycopg2://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}" 49 )
Return the SQLAlchemy URL to use.
@overrides
def
get_database_name(self) -> str:
51 @overrides 52 def get_database_name(self) -> str: 53 """Return the name of the database.""" 54 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