imports:stream#

rai imports:stream [OPTIONS]

Stream data from a Snowflake table or view into RelationalAI.

IMPORTANT

imports:stream is only available for Snowflake-based models.

An import stream utilizes change data capture to synchronize your Snowflake data with your RelationalAI model at an interval of once per minute.

Options#

OptionTypeDescription
--sourceTextThe fully-qualified name of a Snowflake table or view.
--modelTextThe name of the model to which the data in the Snowflake table or view is streamed.

Example#

Use the imports:stream command without any options to interactively select a Snowflake table or view to stream into a RelationalAI model:

❯ rai imports:stream

---------------------------------------------------

▰▰▰▰ Models fetched

? Select a model:
┌──────────────────────────────────────────────────────────────────────────────────────────┐
│❯   2/2                                                                                   │
│❯ myModel                                                                                 │
│  myModel2                                                                                │
└──────────────────────────────────────────────────────────────────────────────────────────┘

▰▰▰▰ Databases fetched

? Select a database:
┌──────────────────────────────────────────────────────────────────────────────────────────┐
│❯   2/2                                                                                   │
│❯ MY_DATABASE1                                                                            │
│  MY_DATABASE2                                                                            │
└──────────────────────────────────────────────────────────────────────────────────────────┘

▰▰▰▰ Schemas fetched

? Select a schema:
┌──────────────────────────────────────────────────────────────────────────────────────────┐
│❯   2/2                                                                                   │
│❯ MY_SCHEMA1                                                                              │
│  MY_SCHEMA2                                                                              │
└──────────────────────────────────────────────────────────────────────────────────────────┘

▰▰▰▰ Tables fetched

? Select tables (tab for multiple):
┌──────────────────────────────────────────────────────────────────────────────────────────┐
│❯   2/2 (0)                                                                               │
│❯ MY_TABLE1                                                                               │
│  MY_TABLE2                                                                               │
└──────────────────────────────────────────────────────────────────────────────────────────┘

▰▰▰▰ Stream for MY_DATABASE1.MY_SCHEMA1.MY_TABLE1 created

---------------------------------------------------

Use the up and down arrow keys to navigate the interactive prompts and press Enter to select an option. You may select multiple tables to import by pressing the tab key. Each prompt is searchable. Simply start typing to filter the available options.

You may provide either of the --model or --source options to skip the interactive prompts. Provide both to create a stream without any prompts:

$ rai imports:stream --model myModel --source MY_DATABASE1.MY_SCHEMA1.MY_TABLE1

---------------------------------------------------

▰▰▰▰ Stream for MY_DATABASE1.MY_SCHEMA1.MY_TABLE1 created

---------------------------------------------------

Once the stream is finished setting up, data from the table may be accessed using the relationalai Python package:

import relationalai as rai

model = rai.Model("myModel")

# Import objects from 'my_table' into the type 'MyTable'.
MyTable = model.Type("MyTable", source="db_name.schema_name.my_table")

See Also#