Metadata-Version: 2.1
Name: pysqliteog
Version: 0.0.3
Summary: a python DBAPI 2.0 interface for sqlite-og
Home-page: https://github.com/aousomran/pysqliteog
Author: Aous Omran
Author-email: aous.omr@gmail.com
Project-URL: Bug Tracker, https://github.com/aousomran/pysqliteog/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: grpcio
Requires-Dist: protobuf

# pysqliteog

A client library for [sqlite-og](https://github.com/aousomran/sqlite-og), based on the
[Python Database API Specification v2.0](https://peps.python.org/pep-0249/)
specification.

# Installation

```shell
pip install pysqliteog
```
This will install `pysqliteog` along with it's dependencies
`grpcio` & `protobuf`

# Usage

### Basic Usage

```python
import pysqliteog

# connect to the database
db = pysqliteog.connect('<host>', '<port>', '<db-name>')
with db.cursor() as cur:
    cur.execute('select 1')
    print(f"{cur.fetchone()}")
db.close()
```

### Using Callbacks

The client allows you to define custom function that
can be used directly in your queries.

```python
import pysqliteog


# define a custom callback function
def say_hello(x):
    return f'hello {x}'


# connect to the database
db = pysqliteog.connect('<host>', '<port>', '<db-name>')
# all custom function must be registered before creating the first cursor
db.create_function('say_hello', 1, say_hello)

with db.cursor() as cur:
    cur.execute('select say_hello(?)', params=['world'])
    # should print "hello world"
    print(f"{cur.fetchone()}")

db.close()
```
