PHPackages                             clue/reactphp-sqlite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. clue/reactphp-sqlite

ActiveLibrary[Database &amp; ORM](/categories/database)

clue/reactphp-sqlite
====================

Async SQLite database, lightweight non-blocking process wrapper around file-based database extension (ext-sqlite3), built on top of ReactPHP.

v1.7.0(1y ago)5738.3k↓34.1%10[10 issues](https://github.com/clue/reactphp-sqlite/issues)19MITPHPPHP &gt;=5.4CI passing

Since May 14Pushed 4mo ago6 watchersCompare

[ Source](https://github.com/clue/reactphp-sqlite)[ Packagist](https://packagist.org/packages/clue/reactphp-sqlite)[ Docs](https://github.com/clue/reactphp-sqlite)[ Fund](https://clue.engineering/support)[ GitHub Sponsors](https://github.com/clue)[ RSS](/packages/clue-reactphp-sqlite/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (10)Used By (19)

clue/reactphp-sqlite
====================

[](#cluereactphp-sqlite)

[![CI status](https://github.com/clue/reactphp-sqlite/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-sqlite/actions)[![code coverage](https://camo.githubusercontent.com/2d45ae33b28ed0c5f14fdba645e579072cf437770a215524795c9eb258581b1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6465253230636f7665726167652d3130302532352d73756363657373)](#tests)[![installs on Packagist](https://camo.githubusercontent.com/f81b3ad07c8d8b00bb0e08223f29911652d694ece92ec9166120f164b70b487c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c75652f72656163747068702d73716c6974653f636f6c6f723d626c7565266c6162656c3d696e7374616c6c732532306f6e2532305061636b6167697374)](https://packagist.org/packages/clue/reactphp-sqlite)

Async SQLite database, lightweight non-blocking process wrapper around file-based database extension (`ext-sqlite3`), built on top of [ReactPHP](https://reactphp.org/).

[SQLite](https://www.sqlite.org/) is a widespread and efficient in-process database. It offers a common SQL interface to process queries to work with its relational data in memory or persist to a simple, portable database file. Its lightweight design makes it an ideal candidate for an embedded database in portable (CLI) applications, test environments and much more. This library provides a simple API to work with your SQLite database from within PHP. Because working with SQLite and the underlying filesystem is inherently blocking, this project is built as a lightweight non-blocking process wrapper around it, so you can query your data without blocking your main application.

- **Async execution of queries** - Send any number of queries (SQL) to SQLite in parallel (automatic queue) and process their responses as soon as results come in. The Promise-based design provides a *sane* interface to working with async results.
- **Lightweight, SOLID design** - Provides a thin abstraction that is [*just good enough*](https://en.wikipedia.org/wiki/Principle_of_good_enough)and does not get in your way. Future or custom commands and events require no changes to be supported.
- **Good test coverage** - Comes with an automated test suite and is regularly tested against actual SQLite databases in the wild.

**Table of contents**

- [Support us](#support-us)
- [Quickstart example](#quickstart-example)
- [Usage](#usage)
    - [Factory](#factory)
        - [open()](#open)
        - [openLazy()](#openlazy)
    - [DatabaseInterface](#databaseinterface)
        - [exec()](#exec)
        - [query()](#query)
        - [quit()](#quit)
        - [close()](#close)
        - [Events](#events)
            - [error event](#error-event)
            - [close event](#close-event)
- [Install](#install)
- [Tests](#tests)
- [License](#license)

Support us
----------

[](#support-us)

We invest a lot of time developing, maintaining and updating our awesome open-source projects. You can help us sustain this high-quality of our work by [becoming a sponsor on GitHub](https://github.com/sponsors/clue). Sponsors get numerous benefits in return, see our [sponsoring page](https://github.com/sponsors/clue)for details.

Let's take these projects to the next level together! 🚀

Quickstart example
------------------

[](#quickstart-example)

The following example code demonstrates how this library can be used to open an existing SQLite database file (or automatically create it on the first run) and then `INSERT` a new record to the database:

```
