All Projects → fauna → Faunadb Python

fauna / Faunadb Python

Licence: other
Python driver for FaunaDB

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Faunadb Python

Faunadb Go
Go driver for FaunaDB
Stars: ✭ 140 (+86.67%)
Mutual labels:  database, driver, drivers, client
Faunadb Js
Javascript driver for FaunaDB
Stars: ✭ 498 (+564%)
Mutual labels:  database, driver, drivers, client
Faunadb Jvm
Scala and Java driver for FaunaDB
Stars: ✭ 50 (-33.33%)
Mutual labels:  database, driver, drivers, client
Nodejs Driver
DataStax Node.js Driver for Apache Cassandra
Stars: ✭ 1,074 (+1332%)
Mutual labels:  database, driver, client
Csharp Driver
DataStax C# Driver for Apache Cassandra
Stars: ✭ 477 (+536%)
Mutual labels:  database, driver, client
Postgres
Postgres.js - The Fastest full featured PostgreSQL client for Node.js
Stars: ✭ 2,193 (+2824%)
Mutual labels:  database, driver, client
Gocql
Package gocql implements a fast and robust Cassandra client for the Go programming language.
Stars: ✭ 2,182 (+2809.33%)
Mutual labels:  database, driver, client
Cdrs
Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async
Stars: ✭ 314 (+318.67%)
Mutual labels:  database, driver, client
Biota
A simple database framework for Fauna
Stars: ✭ 54 (-28%)
Mutual labels:  database, driver, client
Qmgo
Qmgo - The Go driver for MongoDB. It‘s based on official mongo-go-driver but easier to use like Mgo.
Stars: ✭ 444 (+492%)
Mutual labels:  database, driver
Sqlhooks
Attach hooks to any database/sql driver
Stars: ✭ 397 (+429.33%)
Mutual labels:  database, driver
Ruby Pg
A PostgreSQL client library for Ruby
Stars: ✭ 446 (+494.67%)
Mutual labels:  database, client
Rust Mysql Simple
Mysql client library implemented in rust.
Stars: ✭ 415 (+453.33%)
Mutual labels:  database, driver
Hasql
Performant PostgreSQL driver with a flexible mapping API
Stars: ✭ 415 (+453.33%)
Mutual labels:  database, driver
Neo4j Javascript Driver
Neo4j Bolt driver for JavaScript
Stars: ✭ 674 (+798.67%)
Mutual labels:  database, driver
Clickhouse Driver
ClickHouse Python Driver with native interface support
Stars: ✭ 562 (+649.33%)
Mutual labels:  database, driver
Dokany
User mode file system library for windows with FUSE Wrapper
Stars: ✭ 4,055 (+5306.67%)
Mutual labels:  driver, drivers
Arangojs
The official ArangoDB JavaScript driver.
Stars: ✭ 503 (+570.67%)
Mutual labels:  database, driver
Mongo Cxx Driver
C++ Driver for MongoDB
Stars: ✭ 792 (+956%)
Mutual labels:  database, driver
Clj Odbp
A Clojure driver for OrientDB binary protocol
Stars: ✭ 31 (-58.67%)
Mutual labels:  database, driver

FaunaDB Python

.. image:: https://img.shields.io/codecov/c/github/fauna/faunadb-python/master.svg?maxAge=21600 :target: https://codecov.io/gh/fauna/faunadb-python .. image:: https://img.shields.io/pypi/v/faunadb.svg?maxAge=21600 :target: https://pypi.python.org/pypi/faunadb .. image:: https://img.shields.io/badge/license-MPL_2.0-blue.svg?maxAge=2592000 :target: https://raw.githubusercontent.com/fauna/faunadb-python/master/LICENSE

Python driver for FaunaDB <https://fauna.com>_.

Installation

.. code-block:: bash

$ pip install faunadb

Compatibility

The following versions of Python are supported:

  • Python 2.7
  • Python 3.3
  • Python 3.4
  • Python 3.5
  • Python 3.6
  • Python 3.7
  • Python 3.8

Documentation

Driver documentation is available at https://fauna.github.io/faunadb-python/.

See the FaunaDB Documentation <https://docs.fauna.com/>_ for a complete API reference, or look in tests_ for more examples.

Basic Usage

.. code-block:: python

from faunadb import query as q
from faunadb.objects import Ref
from faunadb.client import FaunaClient

client = FaunaClient(secret="your-secret-here")

indexes = client.query(q.paginate(q.indexes()))

print(indexes)

Document Streaming

Fauna supports document streaming, where changes to a streamed document are pushed to all clients subscribing to that document.

The following section provides an example for managing a document stream.

The streaming API is blocking by default, the choice and mechanism for handling concurrent streams is left to the application developer:

.. code-block:: python

from faunadb import query as q
from faunadb.objects import Ref
from faunadb.client import FaunaClient

client = FaunaClient(secret="your-secret-here")

coll = client.query(q.create_collection({"name":"sc"}))
doc  = client.query(q.create(coll["ref"], {"data":{"x": 0}}))

stream = None
def on_start(event):
    print("started stream at %s"%(event.txn))
    client.query(q.update(doc["ref"], {"data": {"x": "updated"}}))

def on_version(event):
    print("on_version event at %s"%(event.txn))
    print("    event: %s"%(event.event))
    stream.close()

def on_error(event):
    print("Received error event %s"%(event))
options = {"fields": ["document", "diff"]}
stream = client.stream(doc["ref"], options, on_start, on_error, on_version)
stream.start()

Building it yourself

Setup


.. code-block:: bash

    $ virtualenv venv
    $ source venv/bin/activate
    $ pip install .


Testing

To run the tests you must have a FaunaDB database available. Then set the environment variable FAUNA_ROOT_KEY to your database's root key. If you use FaunaDB cloud, this is the password you log in with.

Tip: Setting the FAUNA_QUERY_TIMEOUT_MS environment variable will set a timeout in milliseconds for all queries.

Then run make test. To test a single test, use e.g. python -m unittest tests.test_client.ClientTest.test_ping.

Tests can also be run via a Docker container with FAUNA_ROOT_KEY="your-cloud-secret" make docker-test (an alternate Alpine-based Python image can be provided via RUNTIME_IMAGE).

Coverage


To run the tests with coverage, install the coverage dependencies with ``pip install .[coverage]``,
and then run ``make coverage``. A summary will be displayed to the terminal, and a detailed coverage report
will be available at ``htmlcov/index.html``.


Contribute
----------

GitHub pull requests are very welcome.


License
-------

Copyright 2020 `Fauna, Inc. <https://fauna.com>`_

Licensed under the Mozilla Public License, Version 2.0 (the
"License"); you may not use this software except in compliance with
the License. You may obtain a copy of the License at

`http://mozilla.org/MPL/2.0/ <http://mozilla.org/MPL/2.0/>`_

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.


.. _`tests`: https://github.com/fauna/faunadb-python/blob/master/tests/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].