Skip to content

Ibis Connectors

SnowflakeConnector manages input (read) and output (write) connections to Snowflake using Ibis. Parameters may be specified with environment variables of the same name or through the init() method interface. Variables passed through init() take precedence.

Attributes:

Name Type Description
SNOWFLAKE_USER

Snowflake user name.

SNOWFLAKE_ACCOUNT

Snowflake account identifier.

SNOWFLAKE_WAREHOUSE

Snowflake warehouse name.

SNOWFLAKE_ROLE

Snowflake role name.

SNOWFLAKE_PASSWORD

Snowflake password. If not specified, will attempt to authenticate with externalbrowser.

SNOWFLAKE_PKEY

Snowflake private key for key=pair authentification. Private key has precedence over password authetification.

SNOWFLAKE_SOURCE_DATABASE

Snowflake source database name. Use a fully qualified database name (in snowflake terminology DATABASE.SCHEMA; ibis calls this a "database").

SNOWFLAKE_DEST_DATABASE

Snowflake destination database name. Use a fully qualified database name (in snowflake terminology DATABASE.SCHEMA; ibis calls this a "database").

Methods:

Name Description
connect_dest

Establishes and returns an Ibis backend connection to the destination Snowflake database and schema.

connect_source

Establishes and returns an Ibis backend connection to the source Snowflake database and schema.

get_source_table

str) -> Table: Retrieves a table from the source Snowflake database.

get_dest_table

str) -> Table: Retrieves a table from the destination Snowflake database.

create_view

Table, name_table: Optional[str] = None, overwrite: bool = False) -> View: Create a view of a table in the destination Snowflake database.

create_table

Table, name_table: Optional[str] = None, overwrite: bool = False) -> Table: Materialize a table in the destination Snowflake database.

drop_table

str) -> None: Drop a table from the destination Snowflake database.

drop_view

str) -> None: Drop a view from the destination Snowflake database.

Source code in phenex/ibis_connect.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
class SnowflakeConnector:
    """
    SnowflakeConnector manages input (read) and output (write) connections to Snowflake using Ibis. Parameters may be specified with environment variables of the same name or through the __init__() method interface. Variables passed through __init__() take precedence.

    Attributes:
        SNOWFLAKE_USER: Snowflake user name.
        SNOWFLAKE_ACCOUNT: Snowflake account identifier.
        SNOWFLAKE_WAREHOUSE: Snowflake warehouse name.
        SNOWFLAKE_ROLE: Snowflake role name.
        SNOWFLAKE_PASSWORD: Snowflake password. If not specified, will attempt to authenticate with externalbrowser.
        SNOWFLAKE_PKEY: Snowflake private key for key=pair authentification. Private key has precedence over password authetification.
        SNOWFLAKE_SOURCE_DATABASE: Snowflake source database name. Use a fully qualified database name (in snowflake terminology DATABASE.SCHEMA; ibis calls this a "database").
        SNOWFLAKE_DEST_DATABASE: Snowflake destination database name. Use a fully qualified database name (in snowflake terminology DATABASE.SCHEMA; ibis calls this a "database").

    Methods:
        connect_dest() -> BaseBackend:
            Establishes and returns an Ibis backend connection to the destination Snowflake database and schema.

        connect_source() -> BaseBackend:
            Establishes and returns an Ibis backend connection to the source Snowflake database and schema.

        get_source_table(name_table: str) -> Table:
            Retrieves a table from the source Snowflake database.

        get_dest_table(name_table: str) -> Table:
            Retrieves a table from the destination Snowflake database.

        create_view(table: Table, name_table: Optional[str] = None, overwrite: bool = False) -> View:
            Create a view of a table in the destination Snowflake database.

        create_table(table: Table, name_table: Optional[str] = None, overwrite: bool = False) -> Table:
            Materialize a table in the destination Snowflake database.

        drop_table(name_table: str) -> None:
            Drop a table from the destination Snowflake database.

        drop_view(name_table: str) -> None:
            Drop a view from the destination Snowflake database.
    """

    def __init__(
        self,
        SNOWFLAKE_USER: Optional[str] = None,
        SNOWFLAKE_ACCOUNT: Optional[str] = None,
        SNOWFLAKE_WAREHOUSE: Optional[str] = None,
        SNOWFLAKE_ROLE: Optional[str] = None,
        SNOWFLAKE_PASSWORD: Optional[str] = None,
        SNOWFLAKE_PKEY: Optional[str] = None,
        SNOWFLAKE_SOURCE_DATABASE: Optional[str] = None,
        SNOWFLAKE_DEST_DATABASE: Optional[str] = None,
    ):
        self.SNOWFLAKE_USER = SNOWFLAKE_USER or os.environ.get("SNOWFLAKE_USER")
        self.SNOWFLAKE_ACCOUNT = SNOWFLAKE_ACCOUNT or os.environ.get(
            "SNOWFLAKE_ACCOUNT"
        )
        self.SNOWFLAKE_WAREHOUSE = SNOWFLAKE_WAREHOUSE or os.environ.get(
            "SNOWFLAKE_WAREHOUSE"
        )
        self.SNOWFLAKE_ROLE = SNOWFLAKE_ROLE or os.environ.get("SNOWFLAKE_ROLE")
        self.SNOWFLAKE_PASSWORD = SNOWFLAKE_PASSWORD or os.environ.get(
            "SNOWFLAKE_PASSWORD"
        )
        self.SNOWFLAKE_PKEY = SNOWFLAKE_PKEY or os.environ.get("SNOWFLAKE_PKEY")
        source_db = SNOWFLAKE_SOURCE_DATABASE or os.environ.get(
            "SNOWFLAKE_SOURCE_DATABASE"
        )
        self.SNOWFLAKE_SOURCE_DATABASE = source_db.upper() if source_db else None
        dest_db = SNOWFLAKE_DEST_DATABASE or os.environ.get("SNOWFLAKE_DEST_DATABASE")
        self.SNOWFLAKE_DEST_DATABASE = dest_db.upper() if dest_db else None

        try:
            _, _ = self.SNOWFLAKE_SOURCE_DATABASE.split(".")
        except:
            raise ValueError(
                "Use a fully qualified database name (e.g. CATALOG.DATABASE)."
            )
        if self.SNOWFLAKE_DEST_DATABASE:
            try:
                _, _ = self.SNOWFLAKE_DEST_DATABASE.split(".")
            except:
                raise ValueError(
                    "Use a fully qualified database name (e.g. CATALOG.DATABASE)."
                )

        # Managed credentials: when no user/password/key is given, the environment
        # (e.g. a VS Code session) supplies credentials to snowflake.connector.
        self._managed = not (
            self.SNOWFLAKE_USER or self.SNOWFLAKE_PASSWORD or self.SNOWFLAKE_PKEY
        )
        if self._managed:
            required_vars = ["SNOWFLAKE_SOURCE_DATABASE"]
        else:
            required_vars = [
                "SNOWFLAKE_USER",
                "SNOWFLAKE_ACCOUNT",
                "SNOWFLAKE_WAREHOUSE",
                "SNOWFLAKE_ROLE",
                "SNOWFLAKE_SOURCE_DATABASE",
            ]
        self._check_env_vars(required_vars)
        self._check_source_dest()
        # Source and destination live in the same Snowflake account, so a single
        # backend connection can fully-qualify either database/schema. Sharing one
        # connection (instead of opening separate source/dest connections) means
        # source and dest tables belong to the same Ibis backend and can be joined
        # server-side. Ibis refuses to join tables that come from two different
        # connection objects, even when they point at the same account.
        self.source_connection = self.connect_source()
        self.dest_connection = (
            self.source_connection if self.SNOWFLAKE_DEST_DATABASE else None
        )

    def _check_env_vars(self, required_vars: List[str]):
        for var in required_vars:
            if not getattr(self, var):
                raise ValueError(
                    f"Missing required variable: {var}. Set in the environment or pass through __init__()."
                )

    def _check_source_dest(self):
        if self.SNOWFLAKE_DEST_DATABASE and (
            self.SNOWFLAKE_SOURCE_DATABASE == self.SNOWFLAKE_DEST_DATABASE
            and self.SNOWFLAKE_SOURCE_SCHEMA == self.SNOWFLAKE_DEST_SCHEMA
        ):
            raise ValueError("Source and destination locations cannot be the same.")

    def _load_private_key_bytes(self, pkey_value: str) -> bytes:
        try:
            from cryptography.hazmat.primitives import serialization
        except ImportError as e:
            raise ImportError(
                "Key-pair auth (SNOWFLAKE_PKEY) requires the 'cryptography' package."
            ) from e

        if os.path.isfile(pkey_value):
            with open(pkey_value, "rb") as f:
                raw = f.read()
        else:
            candidate = "".join(pkey_value.split())
            try:
                raw = base64.b64decode(candidate, validate=True)
            except Exception as e:
                raise ValueError(
                    "SNOWFLAKE_PKEY must be either an existing file path or a base64-encoded PEM private key."
                ) from e

        if raw.lstrip().startswith(b"-----BEGIN"):
            key = serialization.load_pem_private_key(raw, password=None)
        else:
            key = serialization.load_der_private_key(raw, password=None)
        return key.private_bytes(
            encoding=serialization.Encoding.DER,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.NoEncryption(),
        )

    def _connect(self, database) -> BaseBackend:
        """
        Private method to get a database connection. End users should use connect_source() and connect_dest() to get connections to source and destination databases.
        """
        database, schema = database.split(".")
        #
        # In Ibis speak: catalog = collection of databases
        #                database = collection of tables
        #                schema = columns and column types
        # In snowflake speak: database = collection of schemas = ibis catalog
        #                schema = collection of tables = ibis database
        #
        # In the below connect method, the arguments are the SNOWFLAKE terms.
        #

        # ibis creates JS helper UDFs at connect time, which restricted roles cannot
        # and PhenEx never uses. PHENEX_SNOWFLAKE_UDFS=1 turns them back on.
        create_object_udfs = os.environ.get("PHENEX_SNOWFLAKE_UDFS") == "1"

        if self._managed:
            # connect() with NO arguments makes snowflake.connector load the session's
            # managed credentials; any argument (even database) disables that.
            import snowflake.connector

            sf_con = snowflake.connector.connect()
            with sf_con.cursor() as cur:
                if self.SNOWFLAKE_ROLE:
                    cur.execute(f'USE ROLE "{self.SNOWFLAKE_ROLE}"')
                if self.SNOWFLAKE_WAREHOUSE:
                    cur.execute(f'USE WAREHOUSE "{self.SNOWFLAKE_WAREHOUSE}"')
                cur.execute(f'USE SCHEMA "{database}"."{schema}"')
            return ibis.snowflake.from_connection(
                sf_con, create_object_udfs=create_object_udfs
            )
        elif self.SNOWFLAKE_PKEY:
            return ibis.snowflake.connect(
                user=self.SNOWFLAKE_USER,
                account=self.SNOWFLAKE_ACCOUNT,
                warehouse=self.SNOWFLAKE_WAREHOUSE,
                role=self.SNOWFLAKE_ROLE,
                database=database,
                schema=schema,
                private_key=self._load_private_key_bytes(self.SNOWFLAKE_PKEY),
                create_object_udfs=create_object_udfs,
            )
        elif self.SNOWFLAKE_PASSWORD:
            return ibis.snowflake.connect(
                user=self.SNOWFLAKE_USER,
                password=self.SNOWFLAKE_PASSWORD,
                account=self.SNOWFLAKE_ACCOUNT,
                warehouse=self.SNOWFLAKE_WAREHOUSE,
                role=self.SNOWFLAKE_ROLE,
                database=database,
                schema=schema,
                create_object_udfs=create_object_udfs,
            )
        else:
            return ibis.snowflake.connect(
                user=self.SNOWFLAKE_USER,
                authenticator="externalbrowser",
                account=self.SNOWFLAKE_ACCOUNT,
                warehouse=self.SNOWFLAKE_WAREHOUSE,
                role=self.SNOWFLAKE_ROLE,
                database=database,
                schema=schema,
                create_object_udfs=create_object_udfs,
                # Caches the SSO ID token in the OS keychain so later connects skip the browser.
                client_store_temporary_credential=True,
            )

    def connect_dest(self) -> BaseBackend:
        """
        Establishes and returns an Ibis backend connection to the destination Snowflake database.

        Returns:
            BaseBackend: Ibis backend connection to the destination Snowflake database.
        """
        return self._connect(
            database=self.SNOWFLAKE_DEST_DATABASE,
        )

    def connect_source(self) -> BaseBackend:
        """
        Establishes and returns an Ibis backend connection to the source Snowflake database.

        Returns:
            BaseBackend: Ibis backend connection to the source Snowflake database.
        """
        return self._connect(
            database=self.SNOWFLAKE_SOURCE_DATABASE,
        )

    def get_source_table(self, name_table):
        """
        Retrieves a table from the source Snowflake database.

        Args:
            name_table (str): Name of the table to retrieve.

        Returns:
            Table: Ibis table object from the source Snowflake database.
        """
        return self.source_connection.table(
            name_table, database=self.SNOWFLAKE_SOURCE_DATABASE
        )

    def get_dest_table(self, name_table):
        """
        Retrieves a table from the destination Snowflake database.

        Args:
            name_table (str): Name of the table to retrieve.

        Returns:
            Table: Ibis table object from the destination Snowflake database.
        """
        if self.SNOWFLAKE_DEST_DATABASE is None:
            raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
        return self.dest_connection.table(
            name_table, database=self.SNOWFLAKE_DEST_DATABASE
        )

    def list_dest_tables(self) -> List[str]:
        """Names of all tables in the destination Snowflake database."""
        if self.SNOWFLAKE_DEST_DATABASE is None:
            raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
        return self.dest_connection.list_tables(database=self.SNOWFLAKE_DEST_DATABASE)

    def _get_output_table_name(self, table):
        if table.has_name:
            name_table = table.get_name().split(".")[-1]
        else:
            raise ValueError("Must specify name_table!")
        return name_table

    def create_view(self, table, name_table=None, overwrite=False):
        """
        Create a view of a table in the destination Snowflake database.

        Args:
            table (Table): Ibis table object to create a view from.
            name_table (str, optional): Name of the view to create. Defaults to None.
            overwrite (bool, optional): Whether to overwrite the view if it exists. Defaults to False.

        Returns:
            View: Ibis view object created in the destination Snowflake database.
        """
        if self.SNOWFLAKE_DEST_DATABASE is None:
            raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
        name_table = name_table or self._get_output_table_name(table)

        # Check if the destination database exists, if not, create it
        catalog, database = self.SNOWFLAKE_DEST_DATABASE.split(".")
        if not database in self.dest_connection.list_databases(catalog=catalog):
            self.dest_connection.create_database(name=database, catalog=catalog)

        return self.dest_connection.create_view(
            name=name_table.upper(),
            database=self.SNOWFLAKE_DEST_DATABASE,
            obj=table,
            overwrite=overwrite,
            schema=table.schema(),
        )

    def create_table(self, table, name_table=None, overwrite=False, comment=None):
        """
        Materialize a table in the destination Snowflake database.

        Args:
            table: Ibis table object to materialize.
            name_table (str, optional): Name of the table to create. Defaults to None.
            overwrite: Whether to overwrite the table if it exists. Defaults to False.
            comment: Add a comment about the table.

        Returns:
            Table: Ibis table object created in the destination Snowflake database.
        """
        if self.SNOWFLAKE_DEST_DATABASE is None:
            raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")

        name_table = name_table or self._get_output_table_name(table)

        # Check if the destination database exists, if not, create it
        catalog, database = self.SNOWFLAKE_DEST_DATABASE.split(".")
        if not database in self.dest_connection.list_databases(catalog=catalog):
            self.dest_connection.create_database(name=database, catalog=catalog)

        # Unwrap PhenexTable so ibis sees a proper ir.Expr and performs a
        # server-side CTAS instead of falling back to the memtable/pandas path
        # (which triggers client-side query execution and can produce NULL syntax
        # errors or Arrow schema-mismatch failures on multi-batch Snowflake results).
        from phenex.tables import PhenexTable

        if isinstance(table, PhenexTable):
            table = table.table

        return self.dest_connection.create_table(
            name=name_table.upper(),
            database=self.SNOWFLAKE_DEST_DATABASE,
            obj=table,
            overwrite=overwrite,
            schema=table.schema(),
            comment=comment,
        )

    def drop_table(self, name_table):
        """
        Drop a table from the destination Snowflake database.

        Args:
            name_table (str): Name of the table to drop.

        Returns:
            None
        """
        if self.SNOWFLAKE_DEST_DATABASE is None:
            raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
        return self.dest_connection.drop_table(
            name=name_table, database=self.SNOWFLAKE_DEST_DATABASE
        )

    def drop_view(self, name_table):
        """
        Drop a view from the destination Snowflake database.

        Args:
            name_table (str): Name of the view to drop.

        Returns:
            None
        """
        if self.SNOWFLAKE_DEST_DATABASE is None:
            raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
        return self.dest_connection.drop_view(
            name=name_table, database=self.SNOWFLAKE_DEST_DATABASE
        )

connect_dest()

Establishes and returns an Ibis backend connection to the destination Snowflake database.

Returns:

Name Type Description
BaseBackend BaseBackend

Ibis backend connection to the destination Snowflake database.

Source code in phenex/ibis_connect.py
def connect_dest(self) -> BaseBackend:
    """
    Establishes and returns an Ibis backend connection to the destination Snowflake database.

    Returns:
        BaseBackend: Ibis backend connection to the destination Snowflake database.
    """
    return self._connect(
        database=self.SNOWFLAKE_DEST_DATABASE,
    )

connect_source()

Establishes and returns an Ibis backend connection to the source Snowflake database.

Returns:

Name Type Description
BaseBackend BaseBackend

Ibis backend connection to the source Snowflake database.

Source code in phenex/ibis_connect.py
def connect_source(self) -> BaseBackend:
    """
    Establishes and returns an Ibis backend connection to the source Snowflake database.

    Returns:
        BaseBackend: Ibis backend connection to the source Snowflake database.
    """
    return self._connect(
        database=self.SNOWFLAKE_SOURCE_DATABASE,
    )

create_table(table, name_table=None, overwrite=False, comment=None)

Materialize a table in the destination Snowflake database.

Parameters:

Name Type Description Default
table

Ibis table object to materialize.

required
name_table str

Name of the table to create. Defaults to None.

None
overwrite

Whether to overwrite the table if it exists. Defaults to False.

False
comment

Add a comment about the table.

None

Returns:

Name Type Description
Table

Ibis table object created in the destination Snowflake database.

Source code in phenex/ibis_connect.py
def create_table(self, table, name_table=None, overwrite=False, comment=None):
    """
    Materialize a table in the destination Snowflake database.

    Args:
        table: Ibis table object to materialize.
        name_table (str, optional): Name of the table to create. Defaults to None.
        overwrite: Whether to overwrite the table if it exists. Defaults to False.
        comment: Add a comment about the table.

    Returns:
        Table: Ibis table object created in the destination Snowflake database.
    """
    if self.SNOWFLAKE_DEST_DATABASE is None:
        raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")

    name_table = name_table or self._get_output_table_name(table)

    # Check if the destination database exists, if not, create it
    catalog, database = self.SNOWFLAKE_DEST_DATABASE.split(".")
    if not database in self.dest_connection.list_databases(catalog=catalog):
        self.dest_connection.create_database(name=database, catalog=catalog)

    # Unwrap PhenexTable so ibis sees a proper ir.Expr and performs a
    # server-side CTAS instead of falling back to the memtable/pandas path
    # (which triggers client-side query execution and can produce NULL syntax
    # errors or Arrow schema-mismatch failures on multi-batch Snowflake results).
    from phenex.tables import PhenexTable

    if isinstance(table, PhenexTable):
        table = table.table

    return self.dest_connection.create_table(
        name=name_table.upper(),
        database=self.SNOWFLAKE_DEST_DATABASE,
        obj=table,
        overwrite=overwrite,
        schema=table.schema(),
        comment=comment,
    )

create_view(table, name_table=None, overwrite=False)

Create a view of a table in the destination Snowflake database.

Parameters:

Name Type Description Default
table Table

Ibis table object to create a view from.

required
name_table str

Name of the view to create. Defaults to None.

None
overwrite bool

Whether to overwrite the view if it exists. Defaults to False.

False

Returns:

Name Type Description
View

Ibis view object created in the destination Snowflake database.

Source code in phenex/ibis_connect.py
def create_view(self, table, name_table=None, overwrite=False):
    """
    Create a view of a table in the destination Snowflake database.

    Args:
        table (Table): Ibis table object to create a view from.
        name_table (str, optional): Name of the view to create. Defaults to None.
        overwrite (bool, optional): Whether to overwrite the view if it exists. Defaults to False.

    Returns:
        View: Ibis view object created in the destination Snowflake database.
    """
    if self.SNOWFLAKE_DEST_DATABASE is None:
        raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
    name_table = name_table or self._get_output_table_name(table)

    # Check if the destination database exists, if not, create it
    catalog, database = self.SNOWFLAKE_DEST_DATABASE.split(".")
    if not database in self.dest_connection.list_databases(catalog=catalog):
        self.dest_connection.create_database(name=database, catalog=catalog)

    return self.dest_connection.create_view(
        name=name_table.upper(),
        database=self.SNOWFLAKE_DEST_DATABASE,
        obj=table,
        overwrite=overwrite,
        schema=table.schema(),
    )

drop_table(name_table)

Drop a table from the destination Snowflake database.

Parameters:

Name Type Description Default
name_table str

Name of the table to drop.

required

Returns:

Type Description

None

Source code in phenex/ibis_connect.py
def drop_table(self, name_table):
    """
    Drop a table from the destination Snowflake database.

    Args:
        name_table (str): Name of the table to drop.

    Returns:
        None
    """
    if self.SNOWFLAKE_DEST_DATABASE is None:
        raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
    return self.dest_connection.drop_table(
        name=name_table, database=self.SNOWFLAKE_DEST_DATABASE
    )

drop_view(name_table)

Drop a view from the destination Snowflake database.

Parameters:

Name Type Description Default
name_table str

Name of the view to drop.

required

Returns:

Type Description

None

Source code in phenex/ibis_connect.py
def drop_view(self, name_table):
    """
    Drop a view from the destination Snowflake database.

    Args:
        name_table (str): Name of the view to drop.

    Returns:
        None
    """
    if self.SNOWFLAKE_DEST_DATABASE is None:
        raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
    return self.dest_connection.drop_view(
        name=name_table, database=self.SNOWFLAKE_DEST_DATABASE
    )

get_dest_table(name_table)

Retrieves a table from the destination Snowflake database.

Parameters:

Name Type Description Default
name_table str

Name of the table to retrieve.

required

Returns:

Name Type Description
Table

Ibis table object from the destination Snowflake database.

Source code in phenex/ibis_connect.py
def get_dest_table(self, name_table):
    """
    Retrieves a table from the destination Snowflake database.

    Args:
        name_table (str): Name of the table to retrieve.

    Returns:
        Table: Ibis table object from the destination Snowflake database.
    """
    if self.SNOWFLAKE_DEST_DATABASE is None:
        raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
    return self.dest_connection.table(
        name_table, database=self.SNOWFLAKE_DEST_DATABASE
    )

get_source_table(name_table)

Retrieves a table from the source Snowflake database.

Parameters:

Name Type Description Default
name_table str

Name of the table to retrieve.

required

Returns:

Name Type Description
Table

Ibis table object from the source Snowflake database.

Source code in phenex/ibis_connect.py
def get_source_table(self, name_table):
    """
    Retrieves a table from the source Snowflake database.

    Args:
        name_table (str): Name of the table to retrieve.

    Returns:
        Table: Ibis table object from the source Snowflake database.
    """
    return self.source_connection.table(
        name_table, database=self.SNOWFLAKE_SOURCE_DATABASE
    )

list_dest_tables()

Names of all tables in the destination Snowflake database.

Source code in phenex/ibis_connect.py
def list_dest_tables(self) -> List[str]:
    """Names of all tables in the destination Snowflake database."""
    if self.SNOWFLAKE_DEST_DATABASE is None:
        raise ValueError("Must specify SNOWFLAKE_DEST_DATABASE!")
    return self.dest_connection.list_tables(database=self.SNOWFLAKE_DEST_DATABASE)