MCPcopy
hub / github.com/StructuredLabs/preswald / __init__

Method __init__

preswald/engine/managers/data.py:186–199  ·  view source on GitHub ↗
(
        self, name: str, config: PostgresConfig, duckdb_conn: duckdb.DuckDBPyConnection
    )

Source from the content-addressed store, hash-verified

184
185class PostgresSource(DataSource):
186 def __init__(
187 self, name: str, config: PostgresConfig, duckdb_conn: duckdb.DuckDBPyConnection
188 ):
189 super().__init__(name, duckdb_conn)
190 self.config = config
191
192 # Initialize postgres_scanner extension
193 self._duckdb.execute("INSTALL postgres_scanner;")
194 self._duckdb.execute("LOAD postgres_scanner;")
195
196 self._conn_string = (
197 f"postgresql://{config.user}:{config.password}"
198 f"@{config.host}:{config.port}/{config.dbname}"
199 )
200
201 def query(self, sql: str) -> pd.DataFrame:
202 self._duckdb.execute(f"CALL postgres_attach('{self._conn_string}')")

Callers

nothing calls this directly

Calls 2

executeMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected