# ScyllaDB Driver Connectivity Sample

This sample validates that the Python ScyllaDB driver can connect to Cassandra-on-TiKV and run a CQL smoke test:

1. `CREATE KEYSPACE`
2. `CREATE TABLE`
3. `DESC KEYSPACE`
4. `DESC TABLE keyspace.table`
5. Insert 5 rows
6. Select by primary key
7. Delete 2 rows, then `SELECT ... LIMIT 5`
8. `DROP TABLE`
9. `DROP KEYSPACE`

Runtime:

- Python `3.11.9`
- `scylla-driver==3.28.2`

Create a virtual environment and install dependencies:

```bash
python3.11 -m venv .venv
. .venv/bin/activate
pip install -r samples/scylladb-driver-connectivity/requirements.txt
```

Run it after starting Cassandra-on-TiKV:

```bash
python samples/scylladb-driver-connectivity/connectivity.py
```

Cassandra-on-TiKV requires CQL authentication, so set the username and password to a valid Cassandra-on-TiKV account:

```bash
CASSANDRA_HOSTS=127.0.0.1 \
CASSANDRA_PORT=9042 \
CASSANDRA_USERNAME=root \
CASSANDRA_PASSWORD='your-password' \
python samples/scylladb-driver-connectivity/connectivity.py
```

Environment variables:

| Variable | Default | Description |
| --- | --- | --- |
| `CASSANDRA_HOSTS` | `127.0.0.1` | Comma, semicolon, or space separated seed hosts. |
| `CASSANDRA_PORT` | `9042` | CQL native protocol port. |
| `CASSANDRA_USERNAME` | `cassandra` | Driver authentication username. |
| `CASSANDRA_PASSWORD` | `cassandra` | Driver authentication password. |
| `CASSANDRA_PROTO_VERSION` | `4` | Native protocol version. |
| `CASSANDRA_TIMEOUT` | `5s` | Query timeout. |
| `CASSANDRA_CONNECT_TIMEOUT` | `5s` | Session connection timeout. |
| `CASSANDRA_SAMPLE_KEYSPACE` | `sample_scylla_driver_connectivity` | Keyspace created and dropped by the sample. |
| `CASSANDRA_SAMPLE_TABLE` | `items` | Table created and dropped by the sample. |
| `CASSANDRA_TLS` | `false` | Enable TLS for the CQL connection. |
| `CASSANDRA_TLS_SERVER_NAME` | empty | Optional TLS server name. |
| `CASSANDRA_TLS_SKIP_VERIFY` | `false` | Skip TLS certificate verification for local testing. |
