fauna / faunadb-python

Python driver for Fauna v4

Home Page:https://docs.fauna.com/fauna/v4/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Official Python driver for v4 API of Fauna

image

image

image

Python driver for FaunaDB.

Note: This driver supports an older version of the Fauna API. The latest version of the official Fauna Python Driver is located [here](https://pypi.org/project/faunadb/) (we encourage all new development to use this new version where possible).

Installation

Compatibility

The following versions of Python are supported:

  • Python 3.6
  • Python 3.7
  • Python 3.8
  • Python 3.9
  • Python 3.10

Documentation

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

See the FaunaDB Documentation for a complete API reference, or look in tests for more examples.

Basic Usage

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:

Observing Metrics

Its possible to observe each query's metrics by providing an "observer" callback.

More information on query metrics is available in the FaunaDB Documentation.

Here is a simple example:

Building it yourself

Setup

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.

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/

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.

About

Python driver for Fauna v4

https://docs.fauna.com/fauna/v4/

License:Other


Languages

Language:Python 98.2%Language:Shell 0.9%Language:Makefile 0.8%