>>> import ibis
>>> con = ibis.connect("duckdb://")
Top-level connection APIs
Create and manage backend connections.
connect
ibis.connect(resource, **kwargs)
Connect to resource
, inferring the backend automatically.
The general pattern for ibis.connect
is
= ibis.connect("backend://connection-parameters") con
With many backends that looks like
= ibis.connect("backend://user:password@host:port/database") con
See the connection syntax for each backend for details about URL connection requirements.
Parameters
Name | Type | Description | Default |
---|---|---|---|
resource |
Path | str | A URL or path to the resource to be connected to. | required |
kwargs |
Any | Backend specific keyword arguments | {} |
Examples
Connect to an in-memory DuckDB database:
Connect to an on-disk SQLite database:
>>> con = ibis.connect("sqlite://relative.db")
>>> con = ibis.connect(
"sqlite:///absolute/path/to/data.db"
... # quartodoc: +SKIP ... )
Connect to a PostgreSQL server:
>>> con = ibis.connect(
"postgres://user:password@hostname:5432"
... # quartodoc: +SKIP ... )
Connect to BigQuery:
>>> con = ibis.connect(
"bigquery://my-project/my-dataset"
... # quartodoc: +SKIP ... )
get_backend
ibis.get_backend(expr=None)
Get the current Ibis backend to use for a given expression.
expr An expression to get the backend from. If not passed, the default backend is returned.
Returns
Type | Description |
---|---|
BaseBackend |
The Ibis backend. |
set_backend
ibis.set_backend(backend)
Set the default Ibis backend.
Parameters
Name | Type | Description | Default |
---|---|---|---|
backend |
str | BaseBackend |
May be a backend name or URL, or an existing backend instance. | required |
Examples
You can pass the backend as a name:
>>> import ibis
>>> ibis.set_backend("polars")
Or as a URI
>>> ibis.set_backend(
"postgres://user:password@hostname:5432"
... # quartodoc: +SKIP ... )
Or as an existing backend instance
>>> ibis.set_backend(ibis.duckdb.connect())