★ wanayoo — archive 1999 https://github.com/backmen/python-driverNouvelle recherche | Portail wanayoo
Skip to content
master
Go to file
Code
This branch is 12 commits behind CovenantSQL:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

  • Python -- one of the following:
  • HTTP Client:
  • CovenantSQL Proxy Server:

Installation

Package is uploaded on PyPI.

You can install it with pip:

$ python3 -m pip install PyCovenantSQL

Documentation

Documentation is available online: https://PyCovenantSQL.readthedocs.io/

Key file and database_id can get from: https://testnet.covenantsql.io/quickstart

For support, please refer to the StackOverflow.

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.cursors

# user key file location
key = '/path/to/private.key'

# Connect to the database
connection = pycovenantsql.connect(host='localhost',
                             port=11108,
                             key=key,
                             database='database_id'
                             )

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.

About

Python driver for CovenantSQL

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.