{"id":13877850,"url":"https://github.com/fauna/faunadb-python","last_synced_at":"2025-04-05T16:08:24.623Z","repository":{"id":34731744,"uuid":"38709854","full_name":"fauna/faunadb-python","owner":"fauna","description":"Python driver for FaunaDB v4","archived":false,"fork":false,"pushed_at":"2023-12-13T18:57:02.000Z","size":633,"stargazers_count":124,"open_issues_count":10,"forks_count":25,"subscribers_count":32,"default_branch":"v4","last_synced_at":"2024-04-14T13:04:17.020Z","etag":null,"topics":["client","clients","database","driver","drivers","fauna","faunadb","python"],"latest_commit_sha":null,"homepage":"https://fauna.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fauna.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-07-07T19:26:22.000Z","updated_at":"2024-04-14T13:04:17.020Z","dependencies_parsed_at":"2024-01-13T19:46:59.550Z","dependency_job_id":"f4c2e361-2e34-4ae3-bd01-0a76697bfa10","html_url":"https://github.com/fauna/faunadb-python","commit_stats":{"total_commits":370,"total_committers":32,"mean_commits":11.5625,"dds":0.8189189189189189,"last_synced_commit":"2451066ca1af128cdd14c543ef2fb07a66b8ef9a"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fauna","download_url":"https://codeload.github.com/fauna/faunadb-python/tar.gz/refs/heads/v4","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361691,"owners_count":20926643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","clients","database","driver","drivers","fauna","faunadb","python"],"created_at":"2024-08-06T08:01:29.956Z","updated_at":"2025-04-05T16:08:24.601Z","avatar_url":"https://github.com/fauna.png","language":"Python","readme":"Python driver for Fauna v4 (deprecated)\n==============================================\n\n.. image:: https://img.shields.io/codecov/c/github/fauna/faunadb-python/master.svg?maxAge=21600\n :target: https://codecov.io/gh/fauna/faunadb-python\n.. image:: https://img.shields.io/pypi/v/faunadb.svg?maxAge=21600\n :target: https://pypi.python.org/pypi/faunadb\n.. image:: https://img.shields.io/badge/license-MPL_2.0-blue.svg?maxAge=2592000\n :target: https://raw.githubusercontent.com/fauna/faunadb-python/main/LICENSE\n\n----\n\n**\\*\\*** **WARNING** **\\*\\***\n\nFauna is decommissioning FQL v4 on June 30, 2025.\n\nThis driver is not compatible with FQL v10, the latest version. Fauna accounts\ncreated after August 21, 2024 must use FQL v10. Ensure you migrate existing\nprojects to the official v10 driver by the v4 EOL date:\n`https://github.com/fauna/fauna-python \u003chttps://github.com/fauna/fauna-python\u003e`_\n\nSee the `v4 end of life (EOL) announcement\n\u003chttps://docs.fauna.com/fauna/v4/#fql-v4-end-of-life\u003e`_ and `related FAQ\n\u003chttps://docs.fauna.com/fauna/v4/migration/faq\u003e`_.\n\n----\n\nThe offical Python driver for `Fauna v4 \u003chttps://docs.fauna.com/fauna/v4/\u003e`_\n\nInstallation\n------------\n\n.. code-block:: bash\n\n    $ pip install faunadb\n\n\nCompatibility\n-------------\n\nThe following versions of Python are supported:\n\n* Python 3.6\n* Python 3.7\n* Python 3.8\n* Python 3.9\n* Python 3.10\n\nDocumentation\n-------------\n\nDriver documentation is available at https://fauna.github.io/faunadb-python/4.5.0/api/.\n\nSee the `FaunaDB Documentation \u003chttps://docs.fauna.com/fauna/v4/api/fql/\u003e`__ for a complete API reference, or look in `tests`_\nfor more examples.\n\n\nBasic Usage\n-----------\n\n.. code-block:: python\n\n    from faunadb import query as q\n    from faunadb.objects import Ref\n    from faunadb.client import FaunaClient\n\n    client = FaunaClient(secret=\"your-secret-here\")\n\n    indexes = client.query(q.paginate(q.indexes()))\n\n    print(indexes)\n\nDocument Streaming\n------------------\nFauna supports document streaming, where changes to a streamed document are pushed to all clients subscribing to that document.\n\nThe following section provides an example for managing a document stream.\n\nThe streaming API is blocking by default, the choice and mechanism for handling concurrent streams is left to the application developer:\n\n.. code-block:: python\n\n    from faunadb import query as q\n    from faunadb.objects import Ref\n    from faunadb.client import FaunaClient\n\n    client = FaunaClient(secret=\"your-secret-here\")\n\n    coll = client.query(q.create_collection({\"name\":\"sc\"}))\n    doc  = client.query(q.create(coll[\"ref\"], {\"data\":{\"x\": 0}}))\n\n    stream = None\n    def on_start(event):\n        print(\"started stream at %s\"%(event.txn))\n        client.query(q.update(doc[\"ref\"], {\"data\": {\"x\": \"updated\"}}))\n\n    def on_version(event):\n        print(\"on_version event at %s\"%(event.txn))\n        print(\"    event: %s\"%(event.event))\n        stream.close()\n\n    def on_error(event):\n        print(\"Received error event %s\"%(event))\n    options = {\"fields\": [\"document\", \"diff\"]}\n    stream = client.stream(doc[\"ref\"], options, on_start, on_error, on_version)\n    stream.start()\n\nObserving Metrics\n-----------------\n\nIts possible to observe each query's metrics by providing an \"observer\" callback.\n\nMore information on query metrics is available in the `FaunaDB Documentation \u003chttps://docs.fauna.com/fauna/v4/learn/understanding/plan_billing/billing#perquery\u003e`__.\n\nHere is a simple example:\n\n.. code-block:: python\n\n    from faunadb import query as q\n    from faunadb.client import FaunaClient\n    from faunadb.errors import FaunaError\n\n    # The observer callback, which takes the HTTP response for a query\n    def observe(response):\n        h = response.response_headers\n        print('bytesOut:', h[\"x-compute-ops\"])\n        print('queryTime:', h[\"x-query-time\"])\n        print('readOps:', h[\"x-byte-read-ops\"])\n        print('writeOps:', h[\"x-byte-write-ops\"])\n        print('retries:', h[\"x-txn-retries\"])\n\n    # Connect to a local Fauna Dev instance\n    client = FaunaClient(\n        secret=\"secret\",\n        domain=\"localhost\",\n        scheme=\"http\",\n        port=8443,\n        observer=observe\n    )\n\n    try:\n        result = client.query(\n            q.paginate(q.collections())\n        )\n    except FaunaError as err:\n        print(\"err: \", err)\n    else:\n        print(result)\n\nBuilding it yourself\n--------------------\n\n\nSetup\n~~~~~\n\n.. code-block:: bash\n\n    $ virtualenv venv\n    $ source venv/bin/activate\n    $ pip install .\n\n\nTesting\n~~~~~~~\n\nTo run the tests you must have a FaunaDB database available.\nThen set the environment variable ``FAUNA_ROOT_KEY`` to your database's root key.\nIf you use FaunaDB cloud, this is the password you log in with.\n\nTip: Setting the ``FAUNA_QUERY_TIMEOUT_MS`` environment variable will\nset a timeout in milliseconds for all queries.\n\nThen run ``make test``.\nTo test a single test, use e.g. ``python -m unittest tests.test_client.ClientTest.test_ping``.\n\nTests can also be run via a Docker container with ``FAUNA_ROOT_KEY=\"your-cloud-secret\" make docker-test``\n(an alternate Alpine-based Python image can be provided via `RUNTIME_IMAGE`).\n\n\nCoverage\n~~~~~~~~\n\nTo run the tests with coverage, install the coverage dependencies with ``pip install .[coverage]``,\nand then run ``make coverage``. A summary will be displayed to the terminal, and a detailed coverage report\nwill be available at ``htmlcov/index.html``.\n\n\nContribute\n----------\n\nGitHub pull requests are very welcome.\n\n\nLicense\n-------\n\nCopyright 2020 `Fauna, Inc. \u003chttps://fauna.com\u003e`_\n\nLicensed under the Mozilla Public License, Version 2.0 (the\n\"License\"); you may not use this software except in compliance with\nthe License. You may obtain a copy of the License at\n\n`http://mozilla.org/MPL/2.0/ \u003chttp://mozilla.org/MPL/2.0/\u003e`_\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\nimplied. See the License for the specific language governing\npermissions and limitations under the License.\n\n\n.. _`tests`: https://github.com/fauna/faunadb-python/blob/main/tests/\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffauna%2Ffaunadb-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffauna%2Ffaunadb-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffauna%2Ffaunadb-python/lists"}