cassandra/pylib
Brad Schoening 49c8122d8f
Avoid CQLSH throwing an exception loading .cqlshrc on non-supported platforms
While we do not support Windows as such (at least on server), reviewers evaluated that this might be fixed
as the gains (Windows users using CQLSH to connect to Cassandra running on supported platforms) are justified.

patch by Brad Schoening; reviewed by Brandon Williams, Josh McKenzie for CASSANDRA-20478
2025-05-23 17:49:28 +02:00
..
cqlshlib Avoid CQLSH throwing an exception loading .cqlshrc on non-supported platforms 2025-05-23 17:49:28 +02:00
Dockerfile.ubuntu.py3 Upgrade Python driver to 3.29.0 2024-01-19 17:14:57 +00:00
Dockerfile.ubuntu.py38 Merge branch 'cassandra-3.11' into cassandra-4.0 2023-08-31 22:39:56 +02:00
Dockerfile.ubuntu.py311 Upgrade Python driver to 3.29.0 2024-01-19 17:14:57 +00:00
README.asc Upgrade Python driver to 3.29.0 2024-01-19 17:14:57 +00:00
cassandra-cqlsh-tests.sh Standalone Jenkinsfile 2024-04-04 11:56:36 +02:00
requirements.txt Upgrade Python driver to 3.29.0 2024-01-19 17:14:57 +00: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.

== Requirements
. Python 3.8-3.11 (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.

There are Dockerfiles that can be used to test whether cqlsh works with a default, barebones
Python installation. Assuming Cassandra's source is checked out at `$CASSANDRA_DIR`. To test, first
build the Docker image containing the barebones Python installation -

  $ docker build . --file Dockerfile.ubuntu.py3 -t ubuntu-lts-py3

Next, run cqlsh inside the newly built image -

  $ docker run -v $CASSANDRA_DIR:/code -it ubuntu-lts-py3:latest /code/bin/cqlsh host.docker.internal

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

  $ docker run --net="host" -v $CASSANDRA_DIR:/code -it ubuntu-lts-py3:latest /code/bin/cqlsh

This will try to spawn a cqlsh instance inside the Docker container running Ubuntu LTS (18.04)
with 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.