sqlalchemy-libsql 0.2.0
SQLAlchemy dialect for libSQL
License: MIT
Requires Python: >=3.8
Keywords: sqlalchemy, libsql, database, dialect

<p align="center">
  <a href="https://docs.turso.tech/sdk/python/quickstart">
    <img alt="Turso + SQLAlchemy" src="https://github.com/tursodatabase/libsql-experimental-python/assets/950181/3748f2b3-872e-4cdd-bbe3-78491fd81dfa" width="1000">
    <h3 align="center">Turso + SQLAlchemy (experimental)</h3>
  </a>
</p>

<i><b>This package is experimental, which means it is not consider to be production grade. Furthermore, the package currently only supports Linux and macOS.</b></i>

<p align="center">
  SQLite for Production. Powered by <a href="https://turso.tech/libsql">libSQL</a>.
</p>

<p align="center">
  <a href="https://turso.tech"><strong>Turso</strong></a> ·
  <a href="https://docs.turso.tech/quickstart"><strong>Quickstart</strong></a> ·
  <a href="/examples"><strong>Examples</strong></a> ·
  <a href="https://docs.turso.tech"><strong>Docs</strong></a> ·
  <a href="https://discord.gg/turso"><strong>Discord</strong></a> ·
  <a href="https://blog.turso.tech/"><strong>Blog &amp; Tutorials</strong></a>
</p>

<p align="center">
  <a href="https://pypi.org/project/sqlalchemy-libsql">
    <img src="https://badge.fury.io/py/sqlalchemy-libsql.svg" alt="PyPI" title="PyPI" />
  </a>
  <a href="https://discord.com/invite/4B5D7hYwub">
    <img src="https://dcbadge.vercel.app/api/server/4B5D7hYwub?style=flat" alt="discord activity" title="join us on discord" />
  </a>
</p>

---

## Examples

#### Embedded Replica

```python
import os
from sqlalchemy import create_engine

engine = create_engine(
     "sqlite+libsql:///embedded.db",
     connect_args={
         "auth_token": os.getenv("TURSO_AUTH_TOKEN"),
         "sync_url": f"{os.getenv("TURSO_DATABASE_URL")}",
     },
)
```

#### Remote Database

```python
import os
from sqlalchemy import create_engine

engine = create_engine(
    f"sqlite+libsql://{os.getenv("TURSO_DATABASE_URL")}?secure=true",
    connect_args={
        "auth_token": os.getenv("TURSO_AUTH_TOKEN"),
    },
)
```

#### In-Memory Database

```python
from sqlalchemy import create_engine

engine = create_engine("sqlite+libsql://")
```

#### Local Database

```python
from sqlalchemy import create_engine

engine = create_engine("sqlite+libsql:///local.db")
```

## Documentation

1. [Turso Quickstart](https://docs.turso.tech/quickstart) &mdash; Learn how create and connect your first database.
2. [SDK Quickstart](https://docs.turso.tech/sdk/python/quickstart) &mdash; Learn how to install and execute queries using the libSQL client.
3. [SDK Reference](https://docs.turso.tech/sdk/python/reference) &mdash; Dive deeper with the libSQL SDK reference and examples.

### What is Turso?

[Turso](https://turso.tech) is a SQLite-compatible database built on [libSQL](https://docs.turso.tech/libsql), the Open Contribution fork of SQLite. It enables scaling to hundreds of thousands of databases per organization and supports replication to any location, including your own servers, for microsecond-latency access.

Learn more about what you can do with Turso:

- [Embedded Replicas](https://docs.turso.tech/features/embedded-replicas)
- [Platform API](https://docs.turso.tech/features/platform-api)
- [Branching](https://docs.turso.tech/features/branching)
- [Point-in-Time Recovery](https://docs.turso.tech/features/point-in-time-recovery)