Skip to content

Commit

Permalink
fix: api key injection
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Aug 26, 2023
1 parent 622e34d commit e708c08
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ def write(
streams = {s.stream.name for s in configured_catalog.streams}
logger.info(f"Starting write to DuckDB with {len(streams)} streams")

path = config.get("destination_path")
api_key = config.get("api_key")
path = str(config.get("destination_path"))
path = self._get_destination_path(path)
# check if file exists

# Get and register auth token if applicable
api_key = str(config.get("api_key"))
if api_key:
os.environ["motherduck_token"] = api_key

logger.info(f"Opening DuckDB database at {path}")
con = duckdb.connect(database=path, read_only=False, api_key=api_key)
con = duckdb.connect(database=path, read_only=False)

# create the tables if needed
# con.execute("BEGIN TRANSACTION")
Expand Down Expand Up @@ -161,8 +164,11 @@ def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConn

if path.startswith("/local"):
os.makedirs(os.path.dirname(path), exist_ok=True)

if "api_key" in config:
os.environ["api_key"] = config["api_key"]

con = duckdb.connect(database=path, read_only=False, api_key=api_key)
con = duckdb.connect(database=path, read_only=False)
con.execute("SELECT 1;")

return AirbyteConnectionStatus(status=Status.SUCCEEDED)
Expand Down

0 comments on commit e708c08

Please sign in to comment.