cassandra/pylib/README.asc

31 lines
1.4 KiB
Plaintext

== Overview
This directory contains code primarily for cqlsh. cqlsh uses cqlshlib in this directory.
Currently, cqlshlib supports Python 2 as well as Python 3. Support for Python 3 is relatively
new.
== Requirements
. Python 3 and 2.7 (for cqlsh)
. virtualenv
. Docker (optional)
== Running tests
In order to run tests 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 2.7:
$ docker run -v $CASSANDRA_DIR:/code -it python:2.7-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.