cassandra/pylib
mck be0b73ecba
Merge branch 'cassandra-4.1' into cassandra-5.0
* cassandra-4.1:
  Add option to disable cqlsh history
2026-03-17 23:08:14 +01:00
..
cqlshlib Merge branch 'cassandra-4.1' into cassandra-5.0 2026-03-17 23:08:14 +01:00
README.asc Merge branch 'cassandra-4.1' into cassandra-5.0 2026-03-11 14:20:29 +01:00
cassandra-cqlsh-tests.sh Merge branch 'cassandra-3.0' into cassandra-3.11 2025-12-19 23:34:02 +01:00
requirements.txt Merge branch 'cassandra-4.1' into cassandra-5.0 2025-12-19 23:44:01 +01:00
setup.py Change shebangs of Python scripts to resolve Python 3 from env command 2022-11-18 14:38:03 +01:00

README.asc

== Overview

This directory contains code primarily for cqlsh. cqlsh uses cqlshlib in this directory.
Currently, cqlshlib drops support for Python 2.7. Python 3.6 and 3.7 are deprecated, making Python 3.8+ the recommended version.

== Requirements
. Python 3.8+ (for cqlsh)
. virtualenv
. Docker (optional)

== Running tests

The following environment variables can be configured for the database connection -

. CQL_TEST_HOST, default 127.0.0.1
. CQL_TEST_PORT, default 9042
. CQL_TEST_USER, default 'cassandra'
. CQL_TEST_PWD

You can run tests with a local Cassandra server with:

  $ pytest
  
You can run tests on the python style compliance issues with: 

  $ pycodestyle --ignore E501,E402,E731,W503 **/*.py

In order to run tests in a virtual environment for cqlshlib, run cassandra-cqlsh-tests.sh in this directory. It will
automatically setup a virtualenv with the appropriate version of Python and run tests inside it.

To run cqlsh using publicly available Docker images to connect to Cassandra on the same host, with `$CASSANDRA_DIR` pointing to either the source or install directory where `bin/cqlsh` is located.

For Python 3.11:

  $ docker run -v $CASSANDRA_DIR:/code -it python:3.11-slim /code/bin/cqlsh host.docker.internal

For Python 3.8:

  $ docker run -v $CASSANDRA_DIR:/code -it python:3.8-slim /code/bin/cqlsh host.docker.internal

If `host.docker.internal` isn't supported, then you can use `--net="host"`:

  $ docker run --net="host" -v $CASSANDRA_DIR:/code -it python:3.11-slim /code/bin/cqlsh

This will try to spawn a cqlsh instance inside the Docker container with a minimal Python installation. It will try to connect to the Cassandra instance running on the Docker host at port 9042. If you have Cassandra running elsewhere, replace host.docker.internal with the IP / hostname as usual. Please ensure that the IP / host is accessible from _within_ the Docker container.