Skip to content
Python driver for CovenantSQL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
pycovenantsql Bump version to 0.1.5, add end-to-end encrypt. May 21, 2019
.gitignore Ignore venv and .idea May 20, 2019
LICENSE Create LICENSE Sep 20, 2018
Pipfile
README.rst Support dsn in connect func. Apr 16, 2019
benchmark.py Add benchmark.py Oct 24, 2018
example.py
runtests.py add some unit tests Oct 19, 2018
setup.py Bump version to 0.1.5, add end-to-end encrypt. May 21, 2019

README.rst

PyCovenantSQL

This package contains a pure-Python CovenantSQL client library, based on PEP 249.

NOTE: PyCovenantSQL only support high level APIs defined in PEP 249.

Requirements

Installation

Package is uploaded on PyPI.

You can install it with pip:

$ python3 -m pip install PyCovenantSQL

Documentation

Documentation is available online: http://developers.covenantsql.io/

Key file and dsn can get from: http://developers.covenantsql.io/docs/quickstart

For support, please fire a issue at Github.

Example

The following examples make use of a simple table

CREATE TABLE `users` (
    `id` INTEGER PRIMARY KEY AUTOINCREMENT,
    `email` varchar(255) NOT NULL,
    `password` varchar(255) NOT NULL
);
import pycovenantsql


# Connect to the database with dsn
# host and port are your local CovenantSQL Adapter server
connection = pycovenantsql.connect(
                             dsn='covenantsql://your_database_id',
                             host='localhost',
                             port=11108,
                             )

try:
    with connection.cursor() as cursor:
        # Create a new record
        sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
        cursor.execute(sql, ('webmaster@python.org', 'very-secret'))

    # connection is autocommit. No need to commit in any case.
    # connection.commit()

    with connection.cursor() as cursor:
        # Read a single record
        sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
        cursor.execute(sql, ('webmaster@python.org',))
        result = cursor.fetchone()
        print(result)
finally:
    connection.close()

This example will print:

{'password': 'very-secret', 'id': 1}

Resources

License

PyCovenantSQL is released under the Apache 2.0 License. See LICENSE for more information.

You can’t perform that action at this time.