Skip to main content

DataConnection

Represents a data connection in Datagrok.

Examples

Create a connection to a Postgres database with login parameters

>>> conn_pg = DataConnection(
... name="my_postgres_conn",
... data_source=DataSourceType.Postgres,
... server="localhost",
... port=5432,
... db="mydb",
... new Credentials(login="postgres", password="postgres")
... )
>>> print(conn_pg.host) # Access arbitrary parameter
>>> conn_pg.password = "new_password" # Update arbitrary parameter

Create a connection to an S3 bucket with different parameters

>>> conn_s3 = DataConnection(
... name="my_s3_conn",
... data_source=DataSourceType.S3,
... bucket="my-bucket",
... region="us-west-2",
... new Credentials(accessKey="AKIA...", secretKey="...")
... )
>>> print(conn_s3.bucket) # Access bucket name
>>> conn_s3.region = "us-east-1" # Update region dynamically

Attributes

NameTypeDescription
nameOptional[str]Internal name of the model, used as an identifier.
idOptional[str]Unique identifier for the model instance. Can be None for new instances.
friendly_nameOptional[str]Human-readable name for display purposes. Defaults to None.
created_onOptional[datetime]Timestamp indicating when the model was created. Defaults to None.
updated_onOptional[datetime]Timestamp indicating when the model was last updated. Defaults to None.
namespaceOptional[str]Optional namespace prefix to distinguish models with the same name. Defaults to None.
data_sourceDataSourceTypeType of data source this connection uses.
descriptionOptional[str]Optional textual description of the data connection.
credentialsOptional[Credentials]Authentication credentials used to access the data source.
tagsOptional[List[str]]List of tags associated with the connection for categorization. **kwargs : dict Additional arbitrary parameters stored in the parameters dictionary.

Methods

__init__()

get()

to_dict()

from_dict()

__getattr__()

__getitem__()

__setitem__()

__setattr__()