# `Ecto.Adapters.LibSql.Connection`
[🔗](https://github.com/ocean/ecto_libsql/blob/v0.9.1/lib/ecto/adapters/libsql/connection.ex#L1)

Implementation of Ecto.Adapters.SQL.Connection for LibSQL.

This module handles SQL query generation and DDL operations for LibSQL/SQLite.
It implements the `Ecto.Adapters.SQL.Connection` behaviour, translating Ecto's
query structures into SQLite-compatible SQL.

## Key Responsibilities

- Query generation (`all/1`, `update_all/1`, `delete_all/1`)
- Insert/update/delete operations with RETURNING support
- DDL generation (CREATE TABLE, ALTER TABLE, CREATE INDEX, etc.)
- Constraint name extraction for error handling
- Type mapping between Ecto and SQLite

## SQLite Compatibility

This module ensures generated SQL is compatible with SQLite/LibSQL syntax,
including handling of AUTOINCREMENT, ON CONFLICT clauses, and type affinities.

# `to_constraints`

```elixir
@spec to_constraints(%{message: String.t()}, Keyword.t()) :: Keyword.t()
```

Parse a SQLite error message and map it to a list of Ecto constraint tuples.

Accepts an exception-like map containing a SQLite error `:message` and returns recognised constraint information such as unique, foreign_key or check constraints; returns an empty list when no known constraint pattern is found.

## Parameters

  - error: Map containing a `:message` string produced by SQLite.
  - _opts: Options (unused).

## Returns

  - A keyword list of constraint tuples, for example `[unique: "table_column_index"]`, `[foreign_key: :unknown]`, `[check: "constraint_name"]`, or `[]` when no constraint is recognised.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
