Skip to content

CovenantSQL/cql-python-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Package is uploaded on PyPI.

You can install it with pip:

$ python3 -m pip install PyCovenantSQL

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.

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}

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

About

Python driver for CovenantSQL

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy