## engines.Connection


Named Arrow tables, and the engine that runs plans over them.


Usage

``` python
engines.Connection(engine="duckdb")
```


[sverify.connect()](connect.md#sverify.connect) makes one; the class is for type hints.

- `create(name, schema, rows)` and `put(name, table)` add a table; `get(name)` is the table as given, the input of every engine, and `rows(name)` its rows. A table may instead be one DuckDB reads where it is: a table format's files (`Scan`), or a table DuckDB holds, such as a view's state (`Resident`).
- `table(name)` is an Ibis table bound to it, through an Ibis DuckDB backend that views the Arrow tables. Contracts find a table's data and metadata through it, and Ibis's own `execute` works on it; `con.table(name).get_backend()` is the backend, for SQL of your own.
- `engine` runs plans ([sverify.engines.run](engines.run.md#sverify.engines.run)) unless a call names another.
- The DataFusion engine runs on a private DataFusion session holding the same tables (with the functions Ibis's DataFusion SQL calls), created on first use.


## Parameters


`engine: Engine = ``"duckdb"`  
`"duckdb"`, `"polars"` or `"datafusion"`. Default: `"duckdb"`.


## Attributes


`engine: Engine`  
The engine that runs plans unless a call names another.

`arrow: MutableMapping[str, pa.Table]`  
Deprecated: the tables by name, as Arrow tables; [get](engines.Connection.md#sverify.engines.Connection.get), [rows](engines.Connection.md#sverify.engines.Connection.rows) and [put](engines.Connection.md#sverify.engines.Connection.put) read and write them.

`ibis: Any`  
Deprecated: the Ibis DuckDB backend the bound tables read through; `table(name).get_backend()` is the same backend.

`datafusion: Any`  
Deprecated: the DataFusion session, an internal of the DataFusion engine (#413).


## Raises


`ValueError`  
`engine` is unknown.


## Attributes

| Name | Description |
|----|----|
| [arrow](#arrow) | Deprecated: the tables by name, as Arrow tables. |
| [ibis](#ibis) | Deprecated: the Ibis DuckDB backend the bound tables read through. |

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


#### arrow


Deprecated: the tables by name, as Arrow tables.


`arrow: MutableMapping[str, pa.Table]`


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


#### ibis


Deprecated: the Ibis DuckDB backend the bound tables read through.


`ibis: Any`


## Methods

| Name | Description |
|----|----|
| [create()](#create) | Add table [name](engines.Dialect.md#sverify.engines.Dialect.name) with [schema](Node.schema.md#sverify.Node.schema) (Ibis or Arrow) and [rows](engines.Connection.md#sverify.engines.Connection.rows) (tuples |
| [drop()](#drop) | Remove table [name](engines.Dialect.md#sverify.engines.Dialect.name); nothing happens if there is none. |
| [get()](#get) | Table [name](engines.Dialect.md#sverify.engines.Dialect.name) as it is held: an Arrow table, or a table DuckDB |
| [has()](#has) | Whether the connection has a table [name](engines.Dialect.md#sverify.engines.Dialect.name). |
| [put()](#put) | Add or replace table [name](engines.Dialect.md#sverify.engines.Dialect.name), with doubles as the model has them |
| [rows()](#rows) | The rows of table [name](engines.Dialect.md#sverify.engines.Dialect.name), as tuples in schema order, in the |
| [schema()](#schema) | The Arrow schema of table [name](engines.Dialect.md#sverify.engines.Dialect.name). |
| [table()](#table) | Table [name](engines.Dialect.md#sverify.engines.Dialect.name) as an Ibis table bound to the connection. Its schema is |

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


#### create()


Add table [name](engines.Dialect.md#sverify.engines.Dialect.name) with [schema](Node.schema.md#sverify.Node.schema) (Ibis or Arrow) and [rows](engines.Connection.md#sverify.engines.Connection.rows) (tuples


Usage

``` python
create(name, schema, rows=())
```


in schema order), replacing any table of that name.


##### Parameters


`name: str`  
The table's name.

`schema: ibis.Schema | pa.Schema`  
Its schema, as an Ibis or Arrow schema. An Arrow schema can mark columns NOT NULL (`nullable=False`), which contracts use.

`rows: Iterable[tuple] = ()`  
Tuples in the schema's column order. Default: no rows.


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


#### drop()


Remove table [name](engines.Dialect.md#sverify.engines.Dialect.name); nothing happens if there is none.


Usage

``` python
drop(name)
```


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


#### get()


Table [name](engines.Dialect.md#sverify.engines.Dialect.name) as it is held: an Arrow table, or a table DuckDB


Usage

``` python
get(name)
```


reads where it is (`Scan`, `Resident`).


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


#### has()


Whether the connection has a table [name](engines.Dialect.md#sverify.engines.Dialect.name).


Usage

``` python
has(name)
```


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


#### put()


Add or replace table [name](engines.Dialect.md#sverify.engines.Dialect.name), with doubles as the model has them


Usage

``` python
put(name, table)
```


(`canonical`: one zero, one NaN).

Large and view strings become plain strings, the one string type of Substrait plans. The table is registered with the Ibis backend and, once it exists, the DataFusion session.


##### Parameters


`name: str`  
The table's name.

`table: pa.Table | Native`  
Its contents, or a table DuckDB reads where it is (a `Scan` of files, a `Resident` table), which the Ibis backend views.


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


#### rows()


The rows of table [name](engines.Dialect.md#sverify.engines.Dialect.name), as tuples in schema order, in the


Usage

``` python
rows(name)
```


table's order.


##### Raises


`KeyError`  
The connection has no table [name](engines.Dialect.md#sverify.engines.Dialect.name).


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


#### schema()


The Arrow schema of table [name](engines.Dialect.md#sverify.engines.Dialect.name).


Usage

``` python
schema(name)
```


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


#### table()


Table [name](engines.Dialect.md#sverify.engines.Dialect.name) as an Ibis table bound to the connection. Its schema is


Usage

``` python
table(name)
```


the Arrow table's, nullability included (DuckDB's view of it drops NOT NULL, which contracts read).


##### Parameters


`name: str`  
A table of the connection.


##### Returns


`ir.Table`  
The bound Ibis table.


##### Raises


`KeyError`  
The connection has no table [name](engines.Dialect.md#sverify.engines.Dialect.name).
