Metadata-Version: 2.4
Name: sqlite_rx
Version: 1.3.0
Summary: Python SQLite Client and Server
Author-email: Abhishek Singh <abhishek.singh20141@gmail.com>
Maintainer-email: Abhishek Singh <abhishek.singh20141@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/aosingh/sqlite_rx
Project-URL: Repository, https://github.com/aosingh/sqlite_rx
Project-URL: Issues, https://github.com/aosingh/sqlite_rx/issues
Project-URL: Documentation, https://aosingh.github.io/sqlite_rx/
Project-URL: CI, https://github.com/aosingh/sqlite_rx/actions
Keywords: sqlite,server,client,secure
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: msgpack
Requires-Dist: tornado
Requires-Dist: pyzmq
Requires-Dist: billiard
Provides-Extra: test
Requires-Dist: coverage; extra == "test"
Requires-Dist: pytest; extra == "test"
Provides-Extra: cli
Requires-Dist: click; extra == "cli"
Requires-Dist: rich; extra == "cli"
Requires-Dist: pygments; extra == "cli"
Dynamic: license-file

# sqlite_rx
[![PyPI version](https://badge.fury.io/py/sqlite-rx.svg)](https://pypi.python.org/pypi/sqlite-rx) [![sqlite-rx](https://github.com/aosingh/sqlite_rx/actions/workflows/sqlite_build.yaml/badge.svg)](https://github.com/aosingh/sqlite_rx/actions) [![Downloads](https://pepy.tech/badge/sqlite-rx)](https://pepy.tech/project/sqlite-rx)


[![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)
[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3110/)
[![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3120/)
[![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)](https://www.python.org/downloads/release/python-3130/)
[![Python 3.14](https://img.shields.io/badge/python-3.14-blue.svg)](https://www.python.org/downloads/release/python-3140/)

[![PyPy3.10](https://img.shields.io/badge/python-PyPy3.10-blue.svg)](https://www.pypy.org/download.html)
[![PyPy3.11](https://img.shields.io/badge/python-PyPy3.11-blue.svg)](https://www.pypy.org/download.html)


#### For documentation, usage and examples refer [https://aosingh.github.io/sqlite_rx/](https://aosingh.github.io/sqlite_rx/)

# Introduction

[SQLite](https://www.sqlite.org/index.html) is a lightweight database written in C.
Python has in-built support to interact with the database (locally) which is either stored on disk or in memory.

With `sqlite_rx`, clients should be able to communicate with an `SQLiteServer` in a fast, simple and secure manner and execute queries remotely.

Key Features

- Client and Server for [SQLite](https://www.sqlite.org/index.html) database built using [ZeroMQ](http://zguide.zeromq.org/page:all) as the transport layer and [msgpack](https://msgpack.org/index.html) for serialization/deserialization.
- Authentication using [ZeroMQ Authentication Protocol (ZAP)](https://rfc.zeromq.org/spec:27/ZAP/)
- Encryption using [CurveZMQ](http://curvezmq.org/)
- Generic authorization policy during server startup
- Schedule regular backups for on-disk databases

# Install

```commandline
pip install -U sqlite_rx
```

# Server

`SQLiteServer` runs in a single thread and follows an event-driven concurrency model (using `tornado's` event loop) which minimizes the cost of concurrent client connections. Following snippet shows how you can start the server process.

```python
# server.py

from sqlite_rx.server import SQLiteServer

def main():

    # database is a path-like object giving the pathname
    # of the database file to be opened.

    # You can use ":memory:" to open a database connection to a database
    # that resides in RAM instead of on disk

    server = SQLiteServer(database=":memory:",
                          bind_address="tcp://127.0.0.1:5000")
    server.start()
    server.join()

if __name__ == '__main__':
    main()

```

# Client

The following snippet shows how you can instantiate an `SQLiteClient` and execute a simple `CREATE TABLE` query.

```python
# client.py

from sqlite_rx.client import SQLiteClient

client = SQLiteClient(connect_address="tcp://127.0.0.1:5000")

with client:
  query = "CREATE TABLE stocks (date text, trans text, symbol text, qty real, price real)"
  result = client.execute(query)

```

```text
>> python client.py

{'error': None, 'items': []}
```
