DataStax Python Driver for Apache Cassandra

Overview

DataStax Driver for Apache Cassandra

https://travis-ci.com/datastax/python-driver.png?branch=master

A modern, feature-rich and highly-tunable Python client library for Apache Cassandra (2.1+) and DataStax Enterprise (4.7+) using exclusively Cassandra's binary protocol and Cassandra Query Language v3.

The driver supports Python 2.7, 3.5, 3.6, 3.7 and 3.8.

Note: DataStax products do not support big-endian systems.

Features

Installation

Installation through pip is recommended:

$ pip install cassandra-driver

For more complete installation instructions, see the installation guide.

Documentation

The documentation can be found online here.

A couple of links for getting up to speed:

Object Mapper

cqlengine (originally developed by Blake Eggleston and Jon Haddad, with contributions from the community) is now maintained as an integral part of this package. Refer to documentation here.

Contributing

See CONTRIBUTING.md.

Reporting Problems

Please report any bugs and make any feature requests on the JIRA issue tracker.

If you would like to contribute, please feel free to open a pull request.

Getting Help

Your best options for getting help with the driver are the mailing list and the DataStax Community.

License

Copyright DataStax, Inc.

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

http://www.apache.org/licenses/LICENSE-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.

Comments
  • fir(test/__init__.py): Ignoring DeprecationWarning from

    fir(test/__init__.py): Ignoring DeprecationWarning from "cassandra.io.asyncioreactor"

    • Replace all places that use old async node (@asyncio.coroutine and yield from) and use a new Python syntax (Only for Python v3.5+)
    • Save the old code to allow users with Python v2+ to run our tests.
    • requirements.txt:
      • Install futures package only for Python v2
      • Use the latest sex package version
    opened by Orenef11 16
  • Futures from pypi isn't py3 compatible

    Futures from pypi isn't py3 compatible

    Python3 ships with concurrent.futures so it shouldn't be pulled in but with latest concurrent.futures release on pypi they broke py3 compatibility:

    https://github.com/agronholm/pythonfutures/issues/41

    opened by sontek 16
  • PYTHON-190 Updated date/time support

    PYTHON-190 Updated date/time support

    Superset of https://github.com/datastax/python-driver/pull/241

    Updated to map native types to cql types.

    The integration test will probably not be merged until we find out what versions of C* will have these types to test against.

    I had some general difficulty testing against this branch due to some apparently unrelated server-side errors. https://github.com/josh-mckenzie/cassandra/compare/7523_squashed

    opened by aholmberg 16
  • Add changes to build arm64 wheels

    Add changes to build arm64 wheels

    This PR addresses the issue to build arm64 wheels. To address this issue, I updated travis.yml to include arm64.

    Also there were two additional errors (Master Build Error) I encountered when I triggered master build w/o any changes.

    1. On python: pypy2.7-6.0: Ref: https://travis-ci.com/github/tbbharaj/python-driver/jobs/515470491
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-9Ah7r6/lz4/
    371The command "if [[ $TRAVIS_PYTHON_VERSION != pypy3.5 ]]; then pip install lz4; fi" failed and exited with 1 during .
    
    1. On Python: 3.7 Ref: https://travis-ci.com/github/tbbharaj/python-driver/jobs/515470490
    ERROR: InvocationError for command /home/travis/build/tbbharaj/python-driver/.tox/gevent_loop/bin/nosetests --verbosity=2 --no-path-adjustment /home/travis/build/tbbharaj/python-driver/tests/unit/io/test_geventreactor.py (exited with code -11 (SIGSEGV)) (exited with code -11)
    939___________________________________ summary ____________________________________
    940ERROR:   gevent_loop: commands failed
    941The command "tox -e gevent_loop" exited with 1.
    

    To fix above two errors, I made following changes:

    1. Update setup tools in travis.yml to fix build error in python setup.py egg_info,
    2. Update greenlet version in tox.ini to fix build error in tox -e gevent_loop

    Successful builds Build

    If there are any questions/comments - I'd be happy fix things as needed. I opened the following JIRA issue as well Issue

    Thank you Tanveen

    opened by tbbharaj 15
  • BugFix: It is required to setup() cqlengine before executing queries.

    BugFix: It is required to setup() cqlengine before executing queries.

    Description

    In the concurrent environment, if the global lazy_connect_args is accessed by different threads or coroutine, it will cause exception: It is required to setup() cqlengine before executing queries.

    Fix

    set lazy_connect_args to be threading.local object.

    opened by fatelei 14
  • Token range ownership

    Token range ownership

    According to Cassandra:

    A Range is responsible for the tokens between (left, right]. **

    However, TokenMap.get_replicas() appears to implement [left, right).

    This pull request aims to resolve this disagreement.

    ** Source: https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/dht/Range.java

    opened by damien-instaclustr 12
  • Python host filter policy PYTHON-761

    Python host filter policy PYTHON-761

    I need to write more documentation before we merge, but I wanted to get discussion going on API choices.

    I chose to model the API here almost exactly off the Java driver implementation. The two relevant choices here:

    • the predicate is immutable, and
    • host-filtering takes place at policy-population time, not at query-planning time.

    Does anyone have strong feelings either way about those? Changing either of these is totally doable, but would add more complexity and make the class harder to test.

    opened by mambocab 12
  • Support empty string values in NumpyProtocolHandler

    Support empty string values in NumpyProtocolHandler

    This PR addresses a bug in NumpyProtocolHandler to properly handle empty strings:

    https://datastax-oss.atlassian.net/browse/PYTHON-550
    

    It doesn't support NULL string values however, which requires more invasive changes (e.g. making use of NumPy's missing values support).

    opened by markflorisson 12
  • Fix Python3 bug with Timers and heaps

    Fix Python3 bug with Timers and heaps

    Add comparison operator to allow Timers with the same end time to be pushed into heaps. It's poorly documented, but the warning can be found here: https://docs.python.org/2/library/heapq.html#priority-queue-implementation-notes "In the future with Python 3, tuple comparison breaks for (priority, task) pairs if the priorities are equal and the tasks do not have a default comparison order."

    opened by jonmcevoy 12
  • Cython-based message deserialization (or, how to speed up my python)

    Cython-based message deserialization (or, how to speed up my python)

    This PR adds accelerated versions of ProtocolHandler for message deserialization using Cython. By default the CythonProtocolHandler will be used if python-driver is compiled with Cython.

    This work has been generously supported by SurveyMonkey.

    opened by markflorisson 12
  • PYTHON-609: Align Text and Ascii columns behaviour

    PYTHON-609: Align Text and Ascii columns behaviour

    This PR:

    • Add full unit-tests of CQLengine's Ascii columns.
    • Extend Text columns unit-tests for minimal and maximal length.
    • Thoroughly cover edge-cases on empty / blank / None value strings handling, especially in relation to the required column parameter.
    • Align Ascii column behaviour to Text, by adding min_length and max_length parameter support.
    opened by kdeldycke 11
  • Handle

    Handle "log gone" (PYTHON-1266) at the end of _run_loop

    If log is somehow gone and file exception due to the race mention in PYTHON-1266 it will also inevitably fail for the same reason after the loop so we need to catch the exception there as well.

    I have hit it in some Cassandra dtest:

    Exception in thread asyncore_cassandra_driver_event_loop (most likely raised during interpreter shutdown):
    Traceback (most recent call last):
      File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
      File "/usr/lib/python2.7/threading.py", line 754, in run
      File "/dse/dse-db/bin/../lib/cassandra-driver-internal-only-3.25.0.zip/cassandra-driver-3.25.0/cassandra/io/asyncorereactor.py", line 262, in _run_loop
    <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'debug'
    
    opened by tlasica 1
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • cassandra/cqlengine/models.py
    • tests/integration/advanced/init.py
    • tests/integration/advanced/graph/test_graph_query.py
    • tests/integration/advanced/test_spark.py
    • tests/integration/cqlengine/connections/test_connection.py
    • tests/integration/cqlengine/test_connections.py
    • tests/integration/standard/test_metadata.py
    • tests/integration/standard/test_metrics.py
    • tests/integration/standard/test_prepared_statements.py
    • tests/unit/test_policies.py
    • tests/unit/test_resultset.py

    Fixes:

    • Should read updated rather than udpated.
    • Should read segregation rather than segration.
    • Should read reusable rather than resusable.
    • Should read metadata rather than metatadata.
    • Should read rethrow rather than retrhow.
    • Should read multiple rather than multipltle.
    • Should read graph rather than graoh.
    • Should read geometric rather than geomteric.
    • Should read default rather than defaul.
    • Should read assignment rather than assignement.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    cla-missing 
    opened by timgates42 1
  • PYTHON-1304 Fix test_connection integration test to account for recent changes to stream ID handling

    PYTHON-1304 Fix test_connection integration test to account for recent changes to stream ID handling

    This commit introduced some changes around the handling of orphaned stream IDs. Unfortunately we had a utility class used by at least one of our integration tests which needed to be updated for some of the cases introduced by the improved stream ID handling.

    opened by absurdfarce 0
  • fix(tests/integration/__init__.py): Rename

    fix(tests/integration/__init__.py): Rename "TestCluster" to "IntegrationTestCluster"

    PytestCollectionWarning: cannot collect test class 'TestCluster' because it has a __new__ constructor (from: tests/integration/standard/test_client_warnings.py)
      class TestCluster(object):
    
    opened by Orenef11 1
Owner
DataStax
DataStax
google-cloud-bigtable Apache-2google-cloud-bigtable (🥈31 · ⭐ 3.5K) - Google Cloud Bigtable API client library. Apache-2

Python Client for Google Cloud Bigtable Google Cloud Bigtable is Google's NoSQL Big Data database service. It's the same database that powers many cor

Google APIs 39 Dec 3, 2022
python-beryl, a Python driver for BerylDB.

python-beryl, a Python driver for BerylDB.

BerylDB 3 Nov 24, 2021
ClickHouse Python Driver with native interface support

ClickHouse Python Driver ClickHouse Python Driver with native (TCP) interface support. Asynchronous wrapper is available here: https://github.com/myma

Marilyn System 957 Dec 30, 2022
PyMongo - the Python driver for MongoDB

PyMongo Info: See the mongo site for more information. See GitHub for the latest source. Documentation: Available at pymongo.readthedocs.io Author: Mi

mongodb 3.7k Jan 8, 2023
Motor - the async Python driver for MongoDB and Tornado or asyncio

Motor Info: Motor is a full-featured, non-blocking MongoDB driver for Python Tornado and asyncio applications. Documentation: Available at motor.readt

mongodb 2.1k Dec 26, 2022
Motor - the async Python driver for MongoDB and Tornado or asyncio

Motor Info: Motor is a full-featured, non-blocking MongoDB driver for Python Tornado and asyncio applications. Documentation: Available at motor.readt

mongodb 1.6k Feb 6, 2021
Neo4j Bolt driver for Python

Neo4j Bolt Driver for Python This repository contains the official Neo4j driver for Python. Each driver release (from 4.0 upwards) is built specifical

Neo4j 762 Dec 30, 2022
Pure-python PostgreSQL driver

pg-purepy pg-purepy is a pure-Python PostgreSQL wrapper based on the anyio library. A lot of this library was inspired by the pg8000 library. Credits

Lura Skye 11 May 23, 2022
An asyncio compatible Redis driver, written purely in Python. This is really just a pet-project for me.

asyncredis An asyncio compatible Redis driver. Just a pet-project. Information asyncredis is, like I've said above, just a pet-project for me. I reall

Vish M 1 Dec 25, 2021
asyncio compatible driver for elasticsearch

asyncio client library for elasticsearch aioes is a asyncio compatible library for working with Elasticsearch The project is abandoned aioes is not su

null 97 Sep 5, 2022
Python client for Apache Kafka

Kafka Python client Python client for the Apache Kafka distributed stream processing system. kafka-python is designed to function much like the offici

Dana Powers 5.1k Jan 8, 2023
Apache Libcloud is a Python library which hides differences between different cloud provider APIs and allows you to manage different cloud resources through a unified and easy to use API

Apache Libcloud - a unified interface for the cloud Apache Libcloud is a Python library which hides differences between different cloud provider APIs

The Apache Software Foundation 1.9k Dec 25, 2022
MySQL database connector for Python (with Python 3 support)

mysqlclient This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs. PyPI: https://pypi.org/project/mysqlclient/ Gi

PyMySQL 2.2k Dec 25, 2022
MySQL database connector for Python (with Python 3 support)

mysqlclient This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs. PyPI: https://pypi.org/project/mysqlclient/ Gi

PyMySQL 2.2k Dec 25, 2022
Python interface to Oracle Database conforming to the Python DB API 2.0 specification.

cx_Oracle version 8.2 (Development) cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database

Oracle 841 Dec 21, 2022
PubMed Mapper: A Python library that map PubMed XML to Python object

pubmed-mapper: A Python Library that map PubMed XML to Python object 中文文档 1. Philosophy view UML Programmatically access PubMed article is a common ta

灵魂工具人 33 Dec 8, 2022
Pure Python MySQL Client

PyMySQL Table of Contents Requirements Installation Documentation Example Resources License This package contains a pure-Python MySQL client library,

PyMySQL 7.2k Jan 9, 2023
A supercharged SQLite library for Python

SuperSQLite: a supercharged SQLite library for Python A feature-packed Python package and for utilizing SQLite in Python by Plasticity. It is intended

Plasticity 703 Dec 30, 2022
Redis Python Client

redis-py The Python interface to the Redis key-value store. Python 2 Compatibility Note redis-py 3.5.x will be the last version of redis-py that suppo

Andy McCurdy 11k Dec 29, 2022